24 #include <va/va_dec_hevc.h>
35 #if VA_CHECK_VERSION(1, 2, 0)
36 VAPictureParameterBufferHEVCExtension
pic_param;
50 va_pic->picture_id = VA_INVALID_ID;
51 va_pic->flags = VA_PICTURE_HEVC_INVALID;
52 va_pic->pic_order_cnt = 0;
58 va_pic->pic_order_cnt = pic->
poc;
59 va_pic->flags = rps_type;
62 va_pic->flags |= VA_PICTURE_HEVC_LONG_TERM_REFERENCE;
65 va_pic->flags |= VA_PICTURE_HEVC_FIELD_PIC;
68 va_pic->flags |= VA_PICTURE_HEVC_BOTTOM_FIELD;
75 const HEVCFrame *current_picture =
h->cur_frame;
80 return VA_PICTURE_HEVC_RPS_ST_CURR_BEFORE;
85 return VA_PICTURE_HEVC_RPS_ST_CURR_AFTER;
90 return VA_PICTURE_HEVC_RPS_LT_CURR;
93 if (
h->pps->pps_curr_pic_ref_enabled_flag && current_picture->
poc == pic->
poc)
94 return VA_PICTURE_HEVC_LONG_TERM_REFERENCE;
100 VAPictureParameterBufferHEVC *pp)
102 const HEVCFrame *current_picture =
h->cur_frame;
109 if ((&l->
DPB[j] != current_picture ||
h->pps->pps_curr_pic_ref_enabled_flag) &&
135 int pic_param_size, err,
i;
137 #if VA_CHECK_VERSION(1, 2, 0)
138 int num_comps, pre_palette_size;
141 VAPictureParameterBufferHEVC *pic_param = (VAPictureParameterBufferHEVC *)&pic->
pic_param;
145 *pic_param = (VAPictureParameterBufferHEVC) {
146 .pic_width_in_luma_samples =
sps->width,
147 .pic_height_in_luma_samples =
sps->height,
148 .log2_min_luma_coding_block_size_minus3 =
sps->log2_min_cb_size - 3,
149 .sps_max_dec_pic_buffering_minus1 =
sps->temporal_layer[
sps->max_sub_layers - 1].max_dec_pic_buffering - 1,
150 .log2_diff_max_min_luma_coding_block_size =
sps->log2_diff_max_min_coding_block_size,
151 .log2_min_transform_block_size_minus2 =
sps->log2_min_tb_size - 2,
152 .log2_diff_max_min_transform_block_size =
sps->log2_max_trafo_size -
sps->log2_min_tb_size,
153 .max_transform_hierarchy_depth_inter =
sps->max_transform_hierarchy_depth_inter,
154 .max_transform_hierarchy_depth_intra =
sps->max_transform_hierarchy_depth_intra,
155 .num_short_term_ref_pic_sets =
sps->nb_st_rps,
156 .num_long_term_ref_pic_sps =
sps->num_long_term_ref_pics_sps,
157 .num_ref_idx_l0_default_active_minus1 =
pps->num_ref_idx_l0_default_active - 1,
158 .num_ref_idx_l1_default_active_minus1 =
pps->num_ref_idx_l1_default_active - 1,
159 .init_qp_minus26 =
pps->pic_init_qp_minus26,
160 .pps_cb_qp_offset =
pps->cb_qp_offset,
161 .pps_cr_qp_offset =
pps->cr_qp_offset,
162 .pcm_sample_bit_depth_luma_minus1 =
sps->pcm.bit_depth - 1,
163 .pcm_sample_bit_depth_chroma_minus1 =
sps->pcm.bit_depth_chroma - 1,
164 .log2_min_pcm_luma_coding_block_size_minus3 =
sps->pcm.log2_min_pcm_cb_size - 3,
165 .log2_diff_max_min_pcm_luma_coding_block_size =
sps->pcm.log2_max_pcm_cb_size -
sps->pcm.log2_min_pcm_cb_size,
166 .diff_cu_qp_delta_depth =
pps->diff_cu_qp_delta_depth,
167 .pps_beta_offset_div2 =
pps->beta_offset / 2,
168 .pps_tc_offset_div2 =
pps->tc_offset / 2,
169 .log2_parallel_merge_level_minus2 =
pps->log2_parallel_merge_level - 2,
170 .bit_depth_luma_minus8 =
sps->bit_depth - 8,
171 .bit_depth_chroma_minus8 =
sps->bit_depth - 8,
172 .log2_max_pic_order_cnt_lsb_minus4 =
sps->log2_max_poc_lsb - 4,
173 .num_extra_slice_header_bits =
pps->num_extra_slice_header_bits,
175 .chroma_format_idc =
sps->chroma_format_idc,
176 .tiles_enabled_flag =
pps->tiles_enabled_flag,
177 .separate_colour_plane_flag =
sps->separate_colour_plane,
178 .pcm_enabled_flag =
sps->pcm_enabled,
179 .scaling_list_enabled_flag =
sps->scaling_list_enabled,
180 .transform_skip_enabled_flag =
pps->transform_skip_enabled_flag,
181 .amp_enabled_flag =
sps->amp_enabled,
182 .strong_intra_smoothing_enabled_flag =
sps->strong_intra_smoothing_enabled,
183 .sign_data_hiding_enabled_flag =
pps->sign_data_hiding_flag,
184 .constrained_intra_pred_flag =
pps->constrained_intra_pred_flag,
185 .cu_qp_delta_enabled_flag =
pps->cu_qp_delta_enabled_flag,
186 .weighted_pred_flag =
pps->weighted_pred_flag,
187 .weighted_bipred_flag =
pps->weighted_bipred_flag,
188 .transquant_bypass_enabled_flag =
pps->transquant_bypass_enable_flag,
189 .entropy_coding_sync_enabled_flag =
pps->entropy_coding_sync_enabled_flag,
190 .pps_loop_filter_across_slices_enabled_flag =
pps->seq_loop_filter_across_slices_enabled_flag,
191 .loop_filter_across_tiles_enabled_flag =
pps->loop_filter_across_tiles_enabled_flag,
192 .pcm_loop_filter_disabled_flag =
sps->pcm_loop_filter_disabled,
194 .slice_parsing_fields.bits = {
195 .lists_modification_present_flag =
pps->lists_modification_present_flag,
196 .long_term_ref_pics_present_flag =
sps->long_term_ref_pics_present,
197 .sps_temporal_mvp_enabled_flag =
sps->temporal_mvp_enabled,
198 .cabac_init_present_flag =
pps->cabac_init_present_flag,
199 .output_flag_present_flag =
pps->output_flag_present_flag,
200 .dependent_slice_segments_enabled_flag =
pps->dependent_slice_segments_enabled_flag,
201 .pps_slice_chroma_qp_offsets_present_flag =
pps->pic_slice_level_chroma_qp_offsets_present_flag,
202 .sample_adaptive_offset_enabled_flag =
sps->sao_enabled,
203 .deblocking_filter_override_enabled_flag =
pps->deblocking_filter_override_enabled_flag,
204 .pps_disable_deblocking_filter_flag =
pps->disable_dbf,
205 .slice_segment_header_extension_present_flag =
pps->slice_header_extension_present_flag,
215 if (
pps->tiles_enabled_flag) {
216 pic_param->num_tile_columns_minus1 =
pps->num_tile_columns - 1;
217 pic_param->num_tile_rows_minus1 =
pps->num_tile_rows - 1;
219 for (
i = 0;
i <
pps->num_tile_columns;
i++)
220 pic_param->column_width_minus1[
i] =
pps->column_width[
i] - 1;
223 pic_param->row_height_minus1[
i] =
pps->row_height[
i] - 1;
226 if (
h->sh.short_term_ref_pic_set_sps_flag == 0 &&
h->sh.short_term_rps) {
227 pic_param->st_rps_bits =
h->sh.short_term_ref_pic_set_size;
229 pic_param->st_rps_bits = 0;
232 #if VA_CHECK_VERSION(1, 2, 0)
235 pic->
pic_param.rext = (VAPictureParameterBufferHEVCRext) {
236 .range_extension_pic_fields.bits = {
237 .transform_skip_rotation_enabled_flag =
sps->transform_skip_rotation_enabled,
238 .transform_skip_context_enabled_flag =
sps->transform_skip_context_enabled,
239 .implicit_rdpcm_enabled_flag =
sps->implicit_rdpcm_enabled,
240 .explicit_rdpcm_enabled_flag =
sps->explicit_rdpcm_enabled,
241 .extended_precision_processing_flag =
sps->extended_precision_processing,
242 .intra_smoothing_disabled_flag =
sps->intra_smoothing_disabled,
243 .high_precision_offsets_enabled_flag =
sps->high_precision_offsets_enabled,
244 .persistent_rice_adaptation_enabled_flag =
sps->persistent_rice_adaptation_enabled,
245 .cabac_bypass_alignment_enabled_flag =
sps->cabac_bypass_alignment_enabled,
246 .cross_component_prediction_enabled_flag =
pps->cross_component_prediction_enabled_flag,
247 .chroma_qp_offset_list_enabled_flag =
pps->chroma_qp_offset_list_enabled_flag,
249 .diff_cu_chroma_qp_offset_depth =
pps->diff_cu_chroma_qp_offset_depth,
250 .chroma_qp_offset_list_len_minus1 =
pps->chroma_qp_offset_list_len_minus1,
251 .log2_sao_offset_scale_luma =
pps->log2_sao_offset_scale_luma,
252 .log2_sao_offset_scale_chroma =
pps->log2_sao_offset_scale_chroma,
253 .log2_max_transform_skip_block_size_minus2 =
pps->log2_max_transform_skip_block_size - 2,
256 for (
i = 0;
i < 6;
i++)
257 pic->
pic_param.rext.cb_qp_offset_list[
i] =
pps->cb_qp_offset_list[
i];
259 pic->
pic_param.rext.cr_qp_offset_list[
i] =
pps->cr_qp_offset_list[
i];
262 pre_palette_size =
pps->pps_palette_predictor_initializers_present_flag ?
263 pps->pps_num_palette_predictor_initializers :
264 (
sps->palette_predictor_initializers_present ?
265 sps->sps_num_palette_predictor_initializers :
269 pic->
pic_param.scc = (VAPictureParameterBufferHEVCScc) {
270 .screen_content_pic_fields.bits = {
271 .pps_curr_pic_ref_enabled_flag =
pps->pps_curr_pic_ref_enabled_flag,
272 .palette_mode_enabled_flag =
sps->palette_mode_enabled,
273 .motion_vector_resolution_control_idc =
sps->motion_vector_resolution_control_idc,
274 .intra_boundary_filtering_disabled_flag =
sps->intra_boundary_filtering_disabled,
275 .residual_adaptive_colour_transform_enabled_flag
276 =
pps->residual_adaptive_colour_transform_enabled_flag,
277 .pps_slice_act_qp_offsets_present_flag =
pps->pps_slice_act_qp_offsets_present_flag,
279 .palette_max_size =
sps->palette_max_size,
280 .delta_palette_max_predictor_size =
sps->delta_palette_max_predictor_size,
281 .predictor_palette_size = pre_palette_size,
282 .pps_act_y_qp_offset_plus5 =
pps->residual_adaptive_colour_transform_enabled_flag ?
283 pps->pps_act_y_qp_offset + 5 : 0,
284 .pps_act_cb_qp_offset_plus5 =
pps->residual_adaptive_colour_transform_enabled_flag ?
285 pps->pps_act_cb_qp_offset + 5 : 0,
286 .pps_act_cr_qp_offset_plus3 =
pps->residual_adaptive_colour_transform_enabled_flag ?
287 pps->pps_act_cr_qp_offset + 3 : 0,
290 num_comps =
pps->monochrome_palette_flag ? 1 : 3;
292 for (
int j = 0; j < pre_palette_size; j++)
294 pps->pps_palette_predictor_initializers_present_flag ?
295 pps->pps_palette_predictor_initializer[
comp][j]:
296 sps->sps_palette_predictor_initializer[
comp][j];
301 sizeof(pic->
pic_param) :
sizeof(VAPictureParameterBufferHEVC);
304 VAPictureParameterBufferType,
309 if (
pps->scaling_list_data_present_flag)
311 else if (
sps->scaling_list_enabled)
315 VAIQMatrixBufferHEVC iq_matrix;
318 for (
i = 0;
i < 6;
i++) {
319 for (j = 0; j < 16; j++)
321 for (j = 0; j < 64; j++) {
333 VAIQMatrixBufferType,
334 &iq_matrix,
sizeof(iq_matrix));
350 VASliceParameterBufferHEVC *last_slice_param = (VASliceParameterBufferHEVC *)&pic->
last_slice_param;
357 last_slice_param->LongSliceFlags.fields.LastSliceOfPic = 1;
379 VASliceParameterBufferHEVC *slice_param)
382 #if VA_CHECK_VERSION(1, 2, 0)
388 "or above, which can support REXT related setting correctly.\n");
391 memset(slice_param->delta_luma_weight_l0, 0,
sizeof(slice_param->delta_luma_weight_l0));
392 memset(slice_param->delta_luma_weight_l1, 0,
sizeof(slice_param->delta_luma_weight_l1));
393 memset(slice_param->luma_offset_l0, 0,
sizeof(slice_param->luma_offset_l0));
394 memset(slice_param->luma_offset_l1, 0,
sizeof(slice_param->luma_offset_l1));
395 memset(slice_param->delta_chroma_weight_l0, 0,
sizeof(slice_param->delta_chroma_weight_l0));
396 memset(slice_param->delta_chroma_weight_l1, 0,
sizeof(slice_param->delta_chroma_weight_l1));
397 memset(slice_param->ChromaOffsetL0, 0,
sizeof(slice_param->ChromaOffsetL0));
398 memset(slice_param->ChromaOffsetL1, 0,
sizeof(slice_param->ChromaOffsetL1));
400 slice_param->delta_chroma_log2_weight_denom = 0;
401 slice_param->luma_log2_weight_denom = 0;
410 if (
h->pps->sps->chroma_format_idc) {
442 VAPictureParameterBufferHEVC *pp = (VAPictureParameterBufferHEVC *)&pic->
pic_param;
449 VASurfaceID pid = pp->ReferenceFrames[
i].picture_id;
450 int poc = pp->ReferenceFrames[
i].pic_order_cnt;
465 VASliceParameterBufferHEVC *last_slice_param = (VASliceParameterBufferHEVC *)&pic->
last_slice_param;
473 int err,
i, list_idx;
487 *last_slice_param = (VASliceParameterBufferHEVC) {
488 .slice_data_size =
size,
489 .slice_data_offset = 0,
490 .slice_data_flag = VA_SLICE_DATA_FLAG_ALL,
497 .slice_tc_offset_div2 = sh->
tc_offset / 2,
503 .LongSliceFlags.fields = {
518 memset(last_slice_param->RefPicList, 0xFF,
sizeof(last_slice_param->RefPicList));
520 for (list_idx = 0; list_idx < nb_list; list_idx++) {
521 RefPicList *rpl = &
h->cur_frame->refPicList[list_idx];
529 #if VA_CHECK_VERSION(1, 2, 0)
532 .slice_ext_flags.bits = {
571 #define copy_field(name) h265_raw_ptl->general_ ## name = general_ptl->name
616 #if VA_CHECK_VERSION(1, 2, 0)
617 if (!strcmp(
profile->name,
"Main 12") ||
618 !strcmp(
profile->name,
"Main 12 Intra"))
619 return VAProfileHEVCMain12;
620 else if (!strcmp(
profile->name,
"Main 4:2:2 10") ||
621 !strcmp(
profile->name,
"Main 4:2:2 10 Intra"))
622 return VAProfileHEVCMain422_10;
623 else if (!strcmp(
profile->name,
"Main 4:2:2 12") ||
624 !strcmp(
profile->name,
"Main 4:2:2 12 Intra"))
625 return VAProfileHEVCMain422_12;
626 else if (!strcmp(
profile->name,
"Main 4:4:4") ||
627 !strcmp(
profile->name,
"Main 4:4:4 Intra"))
628 return VAProfileHEVCMain444;
629 else if (!strcmp(
profile->name,
"Main 4:4:4 10") ||
630 !strcmp(
profile->name,
"Main 4:4:4 10 Intra"))
631 return VAProfileHEVCMain444_10;
632 else if (!strcmp(
profile->name,
"Main 4:4:4 12") ||
633 !strcmp(
profile->name,
"Main 4:4:4 12 Intra"))
634 return VAProfileHEVCMain444_12;
635 else if (!strcmp(
profile->name,
"Screen-Extended Main"))
636 return VAProfileHEVCSccMain;
637 else if (!strcmp(
profile->name,
"Screen-Extended Main 10"))
638 return VAProfileHEVCSccMain10;
639 else if (!strcmp(
profile->name,
"Screen-Extended Main 4:4:4"))
640 return VAProfileHEVCSccMain444;
641 #if VA_CHECK_VERSION(1, 8, 0)
642 else if (!strcmp(
profile->name,
"Screen-Extended Main 4:4:4 10"))
643 return VAProfileHEVCSccMain444_10;
647 "not supported with this VA version.\n",
profile->name);
653 return VAProfileHEVCMain;
655 return VAProfileNone;
659 .
p.
name =
"hevc_vaapi",