1 /**************************************************************************
2 *
3 * Copyright 2021 Advanced Micro Devices, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 #include "util/vl_vlc.h"
29 #include "va_private.h"
30
31 #define AV1_REFS_PER_FRAME 7
32 #define AV1_NUM_REF_FRAMES 8
33 #define AV1_MAX_SEGMENTS 8
34 #define AV1_SEG_LVL_MAX 8
35 #define AV1_MAX_CDEF_BITS_ARRAY 8
36 #define AV1_FG_MAX_NUM_Y_POINTS 14
37 #define AV1_FG_MAX_NUM_CBR_POINTS 10
38 #define AV1_FG_MAX_NUM_POS_LUMA 24
39 #define AV1_FG_MAX_NUM_POS_CHROMA 25
40
tile_info(vlVaContext * context,VADecPictureParameterBufferAV1 * av1)41 static void tile_info(vlVaContext *context, VADecPictureParameterBufferAV1 *av1)
42 {
43 unsigned sbCols;
44 unsigned sbRows;
45 int width_sb;
46 int height_sb;
47 unsigned startSb, i;
48 unsigned MiCols = 2 * ((av1->frame_width_minus1 + 8) >> 3);
49 unsigned MiRows = 2 * ((av1->frame_height_minus1 + 8) >> 3);
50
51 unsigned TileColsLog2 = util_logbase2_ceil(av1->tile_cols);
52 unsigned TileRowsLog2 = util_logbase2_ceil(av1->tile_rows);
53
54 if (av1->pic_info_fields.bits.use_superres) {
55 unsigned width = ((av1->frame_width_minus1 + 1) * 8 + av1->superres_scale_denominator / 2)
56 / av1->superres_scale_denominator;
57 MiCols = 2 * (((width - 1) + 8) >> 3);
58 }
59
60 sbCols = (av1->seq_info_fields.fields.use_128x128_superblock) ?
61 ((MiCols + 31) >> 5) : ((MiCols + 15) >> 4);
62 sbRows = (av1->seq_info_fields.fields.use_128x128_superblock) ?
63 ((MiRows + 31) >> 5) : ((MiRows + 15) >> 4);
64
65 width_sb = sbCols;
66 height_sb = sbRows;
67
68 if (av1->pic_info_fields.bits.uniform_tile_spacing_flag) {
69 unsigned tileWidthSb, tileHeightSb;
70
71 tileWidthSb = (sbCols + (1 << TileColsLog2) - 1) >> TileColsLog2;
72 i = 0;
73 for (startSb = 0; startSb < sbCols; startSb += tileWidthSb) {
74 context->desc.av1.picture_parameter.tile_col_start_sb[i] = startSb;
75 context->desc.av1.picture_parameter.width_in_sbs[i] = tileWidthSb;
76 i++;
77 }
78 context->desc.av1.picture_parameter.tile_col_start_sb[i] = sbCols;
79
80 tileHeightSb = (sbRows + (1 << TileRowsLog2) - 1) >> TileRowsLog2;
81 i = 0;
82 for (startSb = 0; startSb < sbRows; startSb += tileHeightSb) {
83 context->desc.av1.picture_parameter.tile_row_start_sb[i] = startSb;
84 context->desc.av1.picture_parameter.height_in_sbs[i] = tileHeightSb;
85 i++;
86 }
87 context->desc.av1.picture_parameter.tile_row_start_sb[i] = sbRows;
88 } else {
89 unsigned widestTileSb = 0;
90
91 startSb = 0;
92 for (i = 0; startSb < sbCols; ++i) {
93 unsigned sizeSb;
94
95 context->desc.av1.picture_parameter.tile_col_start_sb[i] = startSb;
96 sizeSb = (av1->width_in_sbs_minus_1)[i] + 1;
97 context->desc.av1.picture_parameter.width_in_sbs[i] = sizeSb;
98 widestTileSb = MAX2(sizeSb, widestTileSb);
99 startSb += sizeSb;
100 width_sb -= sizeSb;
101 }
102 context->desc.av1.picture_parameter.tile_col_start_sb[i] = startSb + width_sb;
103
104 startSb = 0;
105 for (i = 0; startSb < sbRows; ++i) {
106 unsigned height_in_sbs_minus_1 = (av1->height_in_sbs_minus_1)[i];
107 context->desc.av1.picture_parameter.height_in_sbs[i] = height_in_sbs_minus_1 + 1;
108
109 context->desc.av1.picture_parameter.tile_row_start_sb[i] = startSb;
110 startSb += height_in_sbs_minus_1 + 1;
111 height_sb -= height_in_sbs_minus_1 + 1;
112 }
113 context->desc.av1.picture_parameter.tile_row_start_sb[i] = startSb + height_sb;
114 }
115 }
116
vlVaHandlePictureParameterBufferAV1(vlVaDriver * drv,vlVaContext * context,vlVaBuffer * buf)117 void vlVaHandlePictureParameterBufferAV1(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf)
118 {
119 VADecPictureParameterBufferAV1 *av1 = buf->data;
120 int i, j;
121 bool use_lr;
122
123 assert(buf->size >= sizeof(VADecPictureParameterBufferAV1) && buf->num_elements == 1);
124
125 context->desc.av1.picture_parameter.profile = av1->profile;
126 context->desc.av1.picture_parameter.seq_info_fields.use_128x128_superblock =
127 av1->seq_info_fields.fields.use_128x128_superblock;
128 context->desc.av1.picture_parameter.seq_info_fields.enable_filter_intra =
129 av1->seq_info_fields.fields.enable_filter_intra;
130 context->desc.av1.picture_parameter.seq_info_fields.enable_cdef =
131 av1->seq_info_fields.fields.enable_cdef;
132 context->desc.av1.picture_parameter.seq_info_fields.film_grain_params_present =
133 av1->seq_info_fields.fields.film_grain_params_present;
134 context->desc.av1.picture_parameter.seq_info_fields.enable_intra_edge_filter =
135 av1->seq_info_fields.fields.enable_intra_edge_filter;
136 context->desc.av1.picture_parameter.order_hint_bits_minus_1 = av1->order_hint_bits_minus_1;
137 context->desc.av1.picture_parameter.max_width = av1->frame_width_minus1 + 1;
138 context->desc.av1.picture_parameter.max_height = av1->frame_height_minus1 + 1;
139 context->desc.av1.picture_parameter.seq_info_fields.enable_interintra_compound =
140 av1->seq_info_fields.fields.enable_interintra_compound;
141 context->desc.av1.picture_parameter.seq_info_fields.enable_masked_compound =
142 av1->seq_info_fields.fields.enable_masked_compound;
143 context->desc.av1.picture_parameter.seq_info_fields.enable_dual_filter =
144 av1->seq_info_fields.fields.enable_dual_filter;
145 context->desc.av1.picture_parameter.seq_info_fields.enable_order_hint =
146 av1->seq_info_fields.fields.enable_order_hint;
147 context->desc.av1.picture_parameter.seq_info_fields.enable_jnt_comp =
148 av1->seq_info_fields.fields.enable_jnt_comp;
149
150 context->desc.av1.picture_parameter.seq_info_fields.ref_frame_mvs =
151 av1->seq_info_fields.fields.enable_order_hint;
152
153 context->desc.av1.picture_parameter.bit_depth_idx = av1->bit_depth_idx;
154 context->desc.av1.picture_parameter.seq_info_fields.mono_chrome =
155 av1->seq_info_fields.fields.mono_chrome;
156
157 context->desc.av1.picture_parameter.pic_info_fields.showable_frame =
158 av1->pic_info_fields.bits.showable_frame;
159 context->desc.av1.picture_parameter.pic_info_fields.frame_type =
160 av1->pic_info_fields.bits.frame_type;
161 context->desc.av1.picture_parameter.pic_info_fields.show_frame =
162 av1->pic_info_fields.bits.show_frame;
163 context->desc.av1.picture_parameter.pic_info_fields.error_resilient_mode =
164 av1->pic_info_fields.bits.error_resilient_mode;
165 context->desc.av1.picture_parameter.pic_info_fields.disable_cdf_update =
166 av1->pic_info_fields.bits.disable_cdf_update;
167 context->desc.av1.picture_parameter.pic_info_fields.allow_screen_content_tools =
168 av1->pic_info_fields.bits.allow_screen_content_tools;
169 context->desc.av1.picture_parameter.pic_info_fields.force_integer_mv =
170 av1->pic_info_fields.bits.force_integer_mv;
171 context->desc.av1.picture_parameter.pic_info_fields.allow_intrabc =
172 av1->pic_info_fields.bits.allow_intrabc;
173 context->desc.av1.picture_parameter.pic_info_fields.use_superres =
174 av1->pic_info_fields.bits.use_superres;
175 context->desc.av1.picture_parameter.pic_info_fields.is_motion_mode_switchable =
176 av1->pic_info_fields.bits.is_motion_mode_switchable;
177 context->desc.av1.picture_parameter.pic_info_fields.allow_high_precision_mv =
178 av1->pic_info_fields.bits.allow_high_precision_mv;
179 context->desc.av1.picture_parameter.pic_info_fields.use_ref_frame_mvs =
180 av1->pic_info_fields.bits.use_ref_frame_mvs;
181 context->desc.av1.picture_parameter.pic_info_fields.disable_frame_end_update_cdf =
182 av1->pic_info_fields.bits.disable_frame_end_update_cdf;
183 context->desc.av1.picture_parameter.pic_info_fields.allow_warped_motion =
184 av1->pic_info_fields.bits.allow_warped_motion;
185 context->desc.av1.picture_parameter.pic_info_fields.uniform_tile_spacing_flag =
186 av1->pic_info_fields.bits.uniform_tile_spacing_flag;
187 context->desc.av1.picture_parameter.pic_info_fields.large_scale_tile =
188 av1->pic_info_fields.bits.large_scale_tile;
189
190 context->desc.av1.picture_parameter.matrix_coefficients =
191 av1->matrix_coefficients;
192
193 context->desc.av1.film_grain_target = NULL;
194 if (av1->film_grain_info.film_grain_info_fields.bits.apply_grain)
195 context->desc.av1.picture_parameter.current_frame_id = av1->current_display_picture;
196 else
197 context->desc.av1.picture_parameter.current_frame_id = av1->current_frame;
198
199 context->desc.av1.picture_parameter.order_hint = av1->order_hint;
200 context->desc.av1.picture_parameter.primary_ref_frame = av1->primary_ref_frame;
201 context->desc.av1.picture_parameter.frame_width = av1->frame_width_minus1 + 1;
202 context->desc.av1.picture_parameter.frame_height = av1->frame_height_minus1 + 1;
203
204 context->desc.av1.picture_parameter.superres_scale_denominator =
205 av1->superres_scale_denominator;
206
207 for (i = 0; i < AV1_REFS_PER_FRAME; ++i)
208 context->desc.av1.picture_parameter.ref_frame_idx[i] = av1->ref_frame_idx[i];
209 context->desc.av1.picture_parameter.refresh_frame_flags = 1;
210
211 /* Tile Info */
212 context->desc.av1.picture_parameter.tile_cols = av1->tile_cols;
213 context->desc.av1.picture_parameter.tile_rows = av1->tile_rows;
214 context->desc.av1.picture_parameter.context_update_tile_id = av1->context_update_tile_id;
215 tile_info(context, av1);
216
217 /* Quantization Params */
218 context->desc.av1.picture_parameter.base_qindex = av1->base_qindex;
219 context->desc.av1.picture_parameter.y_dc_delta_q = av1->y_dc_delta_q;
220 context->desc.av1.picture_parameter.u_dc_delta_q = av1->u_dc_delta_q;
221 context->desc.av1.picture_parameter.u_ac_delta_q = av1->u_ac_delta_q;
222 context->desc.av1.picture_parameter.v_dc_delta_q = av1->v_dc_delta_q;
223 context->desc.av1.picture_parameter.v_ac_delta_q = av1->v_ac_delta_q;
224 context->desc.av1.picture_parameter.qmatrix_fields.using_qmatrix =
225 av1->qmatrix_fields.bits.using_qmatrix;
226 context->desc.av1.picture_parameter.qmatrix_fields.qm_y = av1->qmatrix_fields.bits.using_qmatrix
227 ? av1->qmatrix_fields.bits.qm_y : 0xf;
228 context->desc.av1.picture_parameter.qmatrix_fields.qm_u = av1->qmatrix_fields.bits.using_qmatrix
229 ? av1->qmatrix_fields.bits.qm_u : 0xf;
230 context->desc.av1.picture_parameter.qmatrix_fields.qm_v = av1->qmatrix_fields.bits.using_qmatrix
231 ? av1->qmatrix_fields.bits.qm_v : 0xf;
232
233 /* Segmentation Params */
234 context->desc.av1.picture_parameter.seg_info.segment_info_fields.enabled =
235 av1->seg_info.segment_info_fields.bits.enabled;
236 context->desc.av1.picture_parameter.seg_info.segment_info_fields.update_map =
237 av1->seg_info.segment_info_fields.bits.update_map;
238 context->desc.av1.picture_parameter.seg_info.segment_info_fields.update_data =
239 av1->seg_info.segment_info_fields.bits.update_data;
240 context->desc.av1.picture_parameter.seg_info.segment_info_fields.temporal_update =
241 av1->seg_info.segment_info_fields.bits.temporal_update;
242 for (i = 0; i < AV1_MAX_SEGMENTS; ++i) {
243 for (j = 0; j < AV1_SEG_LVL_MAX; ++j)
244 context->desc.av1.picture_parameter.seg_info.feature_data[i][j] =
245 av1->seg_info.feature_data[i][j];
246 context->desc.av1.picture_parameter.seg_info.feature_mask[i] = av1->seg_info.feature_mask[i];
247 }
248
249 /* Delta Q Params */
250 context->desc.av1.picture_parameter.mode_control_fields.delta_q_present_flag =
251 av1->mode_control_fields.bits.delta_q_present_flag;
252 context->desc.av1.picture_parameter.mode_control_fields.log2_delta_q_res =
253 av1->mode_control_fields.bits.log2_delta_q_res;
254
255 /* Delta LF Params */
256 context->desc.av1.picture_parameter.mode_control_fields.delta_lf_present_flag =
257 av1->mode_control_fields.bits.delta_lf_present_flag;
258 context->desc.av1.picture_parameter.mode_control_fields.log2_delta_lf_res =
259 av1->mode_control_fields.bits.log2_delta_lf_res;
260 context->desc.av1.picture_parameter.mode_control_fields.delta_lf_multi =
261 av1->mode_control_fields.bits.delta_lf_multi;
262
263 context->desc.av1.picture_parameter.mode_control_fields.tx_mode =
264 av1->mode_control_fields.bits.tx_mode;
265 context->desc.av1.picture_parameter.mode_control_fields.reference_select =
266 av1->mode_control_fields.bits.reference_select;
267 context->desc.av1.picture_parameter.mode_control_fields.reduced_tx_set_used =
268 av1->mode_control_fields.bits.reduced_tx_set_used;
269 context->desc.av1.picture_parameter.mode_control_fields.skip_mode_present =
270 av1->mode_control_fields.bits.skip_mode_present;
271
272 /* Loop Filter Params */
273 context->desc.av1.picture_parameter.interp_filter = av1->interp_filter;
274 for (i = 0; i < 2; ++i)
275 context->desc.av1.picture_parameter.filter_level[i] = av1->filter_level[i];
276 context->desc.av1.picture_parameter.filter_level_u = av1->filter_level_u;
277 context->desc.av1.picture_parameter.filter_level_v = av1->filter_level_v;
278 context->desc.av1.picture_parameter.loop_filter_info_fields.sharpness_level =
279 av1->loop_filter_info_fields.bits.sharpness_level;
280 context->desc.av1.picture_parameter.loop_filter_info_fields.mode_ref_delta_enabled =
281 av1->loop_filter_info_fields.bits.mode_ref_delta_enabled;
282 context->desc.av1.picture_parameter.loop_filter_info_fields.mode_ref_delta_update =
283 av1->loop_filter_info_fields.bits.mode_ref_delta_update;
284 for (i = 0; i < AV1_NUM_REF_FRAMES; ++i)
285 context->desc.av1.picture_parameter.ref_deltas[i] = av1->ref_deltas[i];
286 for (i = 0; i < 2; ++i)
287 context->desc.av1.picture_parameter.mode_deltas[i] = av1->mode_deltas[i];
288
289 /* CDEF Params */
290 context->desc.av1.picture_parameter.cdef_damping_minus_3 = av1->cdef_damping_minus_3;
291 context->desc.av1.picture_parameter.cdef_bits = av1->cdef_bits;
292 for (i = 0; i < AV1_MAX_CDEF_BITS_ARRAY; ++i) {
293 context->desc.av1.picture_parameter.cdef_y_strengths[i] = av1->cdef_y_strengths[i];
294 context->desc.av1.picture_parameter.cdef_uv_strengths[i] = av1->cdef_uv_strengths[i];
295 }
296
297 /* Loop Restoration Params */
298 context->desc.av1.picture_parameter.loop_restoration_fields.yframe_restoration_type =
299 av1->loop_restoration_fields.bits.yframe_restoration_type;
300 context->desc.av1.picture_parameter.loop_restoration_fields.cbframe_restoration_type =
301 av1->loop_restoration_fields.bits.cbframe_restoration_type;
302 context->desc.av1.picture_parameter.loop_restoration_fields.crframe_restoration_type =
303 av1->loop_restoration_fields.bits.crframe_restoration_type;
304 context->desc.av1.picture_parameter.loop_restoration_fields.lr_unit_shift =
305 av1->loop_restoration_fields.bits.lr_unit_shift;
306 context->desc.av1.picture_parameter.loop_restoration_fields.lr_uv_shift =
307 av1->loop_restoration_fields.bits.lr_uv_shift;
308
309 use_lr = av1->loop_restoration_fields.bits.yframe_restoration_type ||
310 av1->loop_restoration_fields.bits.cbframe_restoration_type ||
311 av1->loop_restoration_fields.bits.crframe_restoration_type;
312
313 if (use_lr) {
314 context->desc.av1.picture_parameter.lr_unit_size[0]
315 = 1 << (6 + av1->loop_restoration_fields.bits.lr_unit_shift);
316 context->desc.av1.picture_parameter.lr_unit_size[1]
317 = 1 << (6 + av1->loop_restoration_fields.bits.lr_unit_shift
318 - av1->loop_restoration_fields.bits.lr_uv_shift);
319 context->desc.av1.picture_parameter.lr_unit_size[2]
320 = context->desc.av1.picture_parameter.lr_unit_size[1];
321 } else {
322 for (i = 0; i < 3; ++i)
323 context->desc.av1.picture_parameter.lr_unit_size[i] = (1 << 8);
324 }
325
326 /* Global Motion Params */
327 for (i = 0; i < ARRAY_SIZE(av1->wm); ++i) {
328 context->desc.av1.picture_parameter.wm[i].wmtype = av1->wm[i].wmtype;
329 context->desc.av1.picture_parameter.wm[i].invalid = av1->wm[i].invalid;
330 for (j = 0; j < ARRAY_SIZE(av1->wm[0].wmmat); ++j)
331 context->desc.av1.picture_parameter.wm[i].wmmat[j] = av1->wm[i].wmmat[j];
332 }
333
334 /* Film Grain Params */
335 context->desc.av1.picture_parameter.film_grain_info.film_grain_info_fields.apply_grain =
336 av1->film_grain_info.film_grain_info_fields.bits.apply_grain;
337 context->desc.av1.picture_parameter.film_grain_info.film_grain_info_fields.chroma_scaling_from_luma =
338 av1->film_grain_info.film_grain_info_fields.bits.chroma_scaling_from_luma;
339 context->desc.av1.picture_parameter.film_grain_info.film_grain_info_fields.grain_scaling_minus_8 =
340 av1->film_grain_info.film_grain_info_fields.bits.grain_scaling_minus_8;
341 context->desc.av1.picture_parameter.film_grain_info.film_grain_info_fields.ar_coeff_lag =
342 av1->film_grain_info.film_grain_info_fields.bits.ar_coeff_lag;
343 context->desc.av1.picture_parameter.film_grain_info.film_grain_info_fields.ar_coeff_shift_minus_6 =
344 av1->film_grain_info.film_grain_info_fields.bits.ar_coeff_shift_minus_6;
345 context->desc.av1.picture_parameter.film_grain_info.film_grain_info_fields.grain_scale_shift =
346 av1->film_grain_info.film_grain_info_fields.bits.grain_scale_shift;
347 context->desc.av1.picture_parameter.film_grain_info.film_grain_info_fields.overlap_flag =
348 av1->film_grain_info.film_grain_info_fields.bits.overlap_flag;
349 context->desc.av1.picture_parameter.film_grain_info.film_grain_info_fields.clip_to_restricted_range =
350 av1->film_grain_info.film_grain_info_fields.bits.clip_to_restricted_range;
351
352 context->desc.av1.picture_parameter.film_grain_info.grain_seed = av1->film_grain_info.grain_seed;
353 context->desc.av1.picture_parameter.film_grain_info.num_y_points = av1->film_grain_info.num_y_points;
354 for (i = 0; i < AV1_FG_MAX_NUM_Y_POINTS; ++i) {
355 context->desc.av1.picture_parameter.film_grain_info.point_y_value[i] =
356 av1->film_grain_info.point_y_value[i];
357 context->desc.av1.picture_parameter.film_grain_info.point_y_scaling[i] =
358 av1->film_grain_info.point_y_scaling[i];
359 }
360 context->desc.av1.picture_parameter.film_grain_info.num_cb_points = av1->film_grain_info.num_cb_points;
361 context->desc.av1.picture_parameter.film_grain_info.num_cr_points = av1->film_grain_info.num_cr_points;
362 for (i = 0; i < AV1_FG_MAX_NUM_CBR_POINTS; ++i) {
363 context->desc.av1.picture_parameter.film_grain_info.point_cb_value[i] =
364 av1->film_grain_info.point_cb_value[i];
365 context->desc.av1.picture_parameter.film_grain_info.point_cb_scaling[i] =
366 av1->film_grain_info.point_cb_scaling[i];
367 context->desc.av1.picture_parameter.film_grain_info.point_cr_value[i] =
368 av1->film_grain_info.point_cr_value[i];
369 context->desc.av1.picture_parameter.film_grain_info.point_cr_scaling[i] =
370 av1->film_grain_info.point_cr_scaling[i];
371 }
372
373 for (i = 0; i < AV1_FG_MAX_NUM_POS_LUMA; ++i)
374 context->desc.av1.picture_parameter.film_grain_info.ar_coeffs_y[i] =
375 av1->film_grain_info.ar_coeffs_y[i];
376 for (i = 0; i < AV1_FG_MAX_NUM_POS_CHROMA; ++i) {
377 context->desc.av1.picture_parameter.film_grain_info.ar_coeffs_cb[i] =
378 av1->film_grain_info.ar_coeffs_cb[i];
379 context->desc.av1.picture_parameter.film_grain_info.ar_coeffs_cr[i] =
380 av1->film_grain_info.ar_coeffs_cr[i];
381 }
382 context->desc.av1.picture_parameter.film_grain_info.cb_mult = av1->film_grain_info.cb_mult;
383 context->desc.av1.picture_parameter.film_grain_info.cb_luma_mult = av1->film_grain_info.cb_luma_mult;
384 context->desc.av1.picture_parameter.film_grain_info.cb_offset = av1->film_grain_info.cb_offset;
385 context->desc.av1.picture_parameter.film_grain_info.cr_mult = av1->film_grain_info.cr_mult;
386 context->desc.av1.picture_parameter.film_grain_info.cr_luma_mult = av1->film_grain_info.cr_luma_mult;
387 context->desc.av1.picture_parameter.film_grain_info.cr_offset = av1->film_grain_info.cr_offset;
388
389 for (i = 0 ; i < AV1_NUM_REF_FRAMES; ++i) {
390 if (av1->pic_info_fields.bits.frame_type == 0 && av1->pic_info_fields.bits.show_frame)
391 context->desc.av1.ref[i] = NULL;
392 else
393 vlVaGetReferenceFrame(drv, av1->ref_frame_map[i], &context->desc.av1.ref[i]);
394 }
395
396 context->desc.av1.slice_parameter.slice_count = 0;
397 }
398
vlVaHandleSliceParameterBufferAV1(vlVaContext * context,vlVaBuffer * buf)399 void vlVaHandleSliceParameterBufferAV1(vlVaContext *context, vlVaBuffer *buf)
400 {
401 VASliceParameterBufferAV1 *av1 = buf->data;
402
403 for (uint32_t buffer_idx = 0; buffer_idx < buf->num_elements; buffer_idx++, av1++) {
404 uint32_t slice_index = context->desc.av1.slice_parameter.slice_count + buffer_idx;
405
406 ASSERTED const size_t max_pipe_av1_slices = ARRAY_SIZE(context->desc.av1.slice_parameter.slice_data_offset);
407 assert(slice_index < max_pipe_av1_slices);
408
409 context->desc.av1.slice_parameter.slice_data_size[slice_index] = av1->slice_data_size;
410 context->desc.av1.slice_parameter.slice_data_offset[slice_index] =
411 context->slice_data_offset + av1->slice_data_offset;
412 context->desc.av1.slice_parameter.slice_data_row[slice_index] = av1->tile_row;
413 context->desc.av1.slice_parameter.slice_data_col[slice_index] = av1->tile_column;
414 context->desc.av1.slice_parameter.slice_data_anchor_frame_idx[slice_index] = av1->anchor_frame_idx;
415 }
416 context->desc.av1.slice_parameter.slice_count += buf->num_elements;
417 }
418