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