24 #include <va/va_dec_hevc.h>
34 #if VA_CHECK_VERSION(1, 2, 0)
35 VAPictureParameterBufferHEVCExtension
pic_param;
49 va_pic->picture_id = VA_INVALID_ID;
50 va_pic->flags = VA_PICTURE_HEVC_INVALID;
51 va_pic->pic_order_cnt = 0;
57 va_pic->pic_order_cnt = pic->
poc;
58 va_pic->flags = rps_type;
61 va_pic->flags |= VA_PICTURE_HEVC_LONG_TERM_REFERENCE;
64 va_pic->flags |= VA_PICTURE_HEVC_FIELD_PIC;
67 va_pic->flags |= VA_PICTURE_HEVC_BOTTOM_FIELD;
78 return VA_PICTURE_HEVC_RPS_ST_CURR_BEFORE;
83 return VA_PICTURE_HEVC_RPS_ST_CURR_AFTER;
88 return VA_PICTURE_HEVC_RPS_LT_CURR;
127 int pic_param_size, err,
i;
129 VAPictureParameterBufferHEVC *pic_param = (VAPictureParameterBufferHEVC *)&pic->
pic_param;
133 *pic_param = (VAPictureParameterBufferHEVC) {
134 .pic_width_in_luma_samples =
sps->width,
135 .pic_height_in_luma_samples =
sps->height,
136 .log2_min_luma_coding_block_size_minus3 =
sps->log2_min_cb_size - 3,
137 .sps_max_dec_pic_buffering_minus1 =
sps->temporal_layer[
sps->max_sub_layers - 1].max_dec_pic_buffering - 1,
138 .log2_diff_max_min_luma_coding_block_size =
sps->log2_diff_max_min_coding_block_size,
139 .log2_min_transform_block_size_minus2 =
sps->log2_min_tb_size - 2,
140 .log2_diff_max_min_transform_block_size =
sps->log2_max_trafo_size -
sps->log2_min_tb_size,
141 .max_transform_hierarchy_depth_inter =
sps->max_transform_hierarchy_depth_inter,
142 .max_transform_hierarchy_depth_intra =
sps->max_transform_hierarchy_depth_intra,
143 .num_short_term_ref_pic_sets =
sps->nb_st_rps,
144 .num_long_term_ref_pic_sps =
sps->num_long_term_ref_pics_sps,
145 .num_ref_idx_l0_default_active_minus1 =
pps->num_ref_idx_l0_default_active - 1,
146 .num_ref_idx_l1_default_active_minus1 =
pps->num_ref_idx_l1_default_active - 1,
147 .init_qp_minus26 =
pps->pic_init_qp_minus26,
148 .pps_cb_qp_offset =
pps->cb_qp_offset,
149 .pps_cr_qp_offset =
pps->cr_qp_offset,
150 .pcm_sample_bit_depth_luma_minus1 =
sps->pcm.bit_depth - 1,
151 .pcm_sample_bit_depth_chroma_minus1 =
sps->pcm.bit_depth_chroma - 1,
152 .log2_min_pcm_luma_coding_block_size_minus3 =
sps->pcm.log2_min_pcm_cb_size - 3,
153 .log2_diff_max_min_pcm_luma_coding_block_size =
sps->pcm.log2_max_pcm_cb_size -
sps->pcm.log2_min_pcm_cb_size,
154 .diff_cu_qp_delta_depth =
pps->diff_cu_qp_delta_depth,
155 .pps_beta_offset_div2 =
pps->beta_offset / 2,
156 .pps_tc_offset_div2 =
pps->tc_offset / 2,
157 .log2_parallel_merge_level_minus2 =
pps->log2_parallel_merge_level - 2,
158 .bit_depth_luma_minus8 =
sps->bit_depth - 8,
159 .bit_depth_chroma_minus8 =
sps->bit_depth - 8,
160 .log2_max_pic_order_cnt_lsb_minus4 =
sps->log2_max_poc_lsb - 4,
161 .num_extra_slice_header_bits =
pps->num_extra_slice_header_bits,
163 .chroma_format_idc =
sps->chroma_format_idc,
164 .tiles_enabled_flag =
pps->tiles_enabled_flag,
165 .separate_colour_plane_flag =
sps->separate_colour_plane_flag,
166 .pcm_enabled_flag =
sps->pcm_enabled_flag,
167 .scaling_list_enabled_flag =
sps->scaling_list_enable_flag,
168 .transform_skip_enabled_flag =
pps->transform_skip_enabled_flag,
169 .amp_enabled_flag =
sps->amp_enabled_flag,
170 .strong_intra_smoothing_enabled_flag =
sps->sps_strong_intra_smoothing_enable_flag,
171 .sign_data_hiding_enabled_flag =
pps->sign_data_hiding_flag,
172 .constrained_intra_pred_flag =
pps->constrained_intra_pred_flag,
173 .cu_qp_delta_enabled_flag =
pps->cu_qp_delta_enabled_flag,
174 .weighted_pred_flag =
pps->weighted_pred_flag,
175 .weighted_bipred_flag =
pps->weighted_bipred_flag,
176 .transquant_bypass_enabled_flag =
pps->transquant_bypass_enable_flag,
177 .entropy_coding_sync_enabled_flag =
pps->entropy_coding_sync_enabled_flag,
178 .pps_loop_filter_across_slices_enabled_flag =
pps->seq_loop_filter_across_slices_enabled_flag,
179 .loop_filter_across_tiles_enabled_flag =
pps->loop_filter_across_tiles_enabled_flag,
180 .pcm_loop_filter_disabled_flag =
sps->pcm.loop_filter_disable_flag,
182 .slice_parsing_fields.bits = {
183 .lists_modification_present_flag =
pps->lists_modification_present_flag,
184 .long_term_ref_pics_present_flag =
sps->long_term_ref_pics_present_flag,
185 .sps_temporal_mvp_enabled_flag =
sps->sps_temporal_mvp_enabled_flag,
186 .cabac_init_present_flag =
pps->cabac_init_present_flag,
187 .output_flag_present_flag =
pps->output_flag_present_flag,
188 .dependent_slice_segments_enabled_flag =
pps->dependent_slice_segments_enabled_flag,
189 .pps_slice_chroma_qp_offsets_present_flag =
pps->pic_slice_level_chroma_qp_offsets_present_flag,
190 .sample_adaptive_offset_enabled_flag =
sps->sao_enabled,
191 .deblocking_filter_override_enabled_flag =
pps->deblocking_filter_override_enabled_flag,
192 .pps_disable_deblocking_filter_flag =
pps->disable_dbf,
193 .slice_segment_header_extension_present_flag =
pps->slice_header_extension_present_flag,
203 if (
pps->tiles_enabled_flag) {
204 pic_param->num_tile_columns_minus1 =
pps->num_tile_columns - 1;
205 pic_param->num_tile_rows_minus1 =
pps->num_tile_rows - 1;
207 for (
i = 0;
i <
pps->num_tile_columns;
i++)
208 pic_param->column_width_minus1[
i] =
pps->column_width[
i] - 1;
211 pic_param->row_height_minus1[
i] =
pps->row_height[
i] - 1;
214 if (
h->sh.short_term_ref_pic_set_sps_flag == 0 &&
h->sh.short_term_rps) {
215 pic_param->st_rps_bits =
h->sh.short_term_ref_pic_set_size;
217 pic_param->st_rps_bits = 0;
220 #if VA_CHECK_VERSION(1, 2, 0)
222 pic->
pic_param.rext = (VAPictureParameterBufferHEVCRext) {
223 .range_extension_pic_fields.bits = {
224 .transform_skip_rotation_enabled_flag =
sps->transform_skip_rotation_enabled_flag,
225 .transform_skip_context_enabled_flag =
sps->transform_skip_context_enabled_flag,
226 .implicit_rdpcm_enabled_flag =
sps->implicit_rdpcm_enabled_flag,
227 .explicit_rdpcm_enabled_flag =
sps->explicit_rdpcm_enabled_flag,
228 .extended_precision_processing_flag =
sps->extended_precision_processing_flag,
229 .intra_smoothing_disabled_flag =
sps->intra_smoothing_disabled_flag,
230 .high_precision_offsets_enabled_flag =
sps->high_precision_offsets_enabled_flag,
231 .persistent_rice_adaptation_enabled_flag =
sps->persistent_rice_adaptation_enabled_flag,
232 .cabac_bypass_alignment_enabled_flag =
sps->cabac_bypass_alignment_enabled_flag,
233 .cross_component_prediction_enabled_flag =
pps->cross_component_prediction_enabled_flag,
234 .chroma_qp_offset_list_enabled_flag =
pps->chroma_qp_offset_list_enabled_flag,
236 .diff_cu_chroma_qp_offset_depth =
pps->diff_cu_chroma_qp_offset_depth,
237 .chroma_qp_offset_list_len_minus1 =
pps->chroma_qp_offset_list_len_minus1,
238 .log2_sao_offset_scale_luma =
pps->log2_sao_offset_scale_luma,
239 .log2_sao_offset_scale_chroma =
pps->log2_sao_offset_scale_chroma,
240 .log2_max_transform_skip_block_size_minus2 =
pps->log2_max_transform_skip_block_size - 2,
243 for (
i = 0;
i < 6;
i++)
244 pic->
pic_param.rext.cb_qp_offset_list[
i] =
pps->cb_qp_offset_list[
i];
246 pic->
pic_param.rext.cr_qp_offset_list[
i] =
pps->cr_qp_offset_list[
i];
250 sizeof(pic->
pic_param) :
sizeof(VAPictureParameterBufferHEVC);
253 VAPictureParameterBufferType,
258 if (
pps->scaling_list_data_present_flag)
260 else if (
sps->scaling_list_enable_flag)
264 VAIQMatrixBufferHEVC iq_matrix;
267 for (
i = 0;
i < 6;
i++) {
268 for (j = 0; j < 16; j++)
270 for (j = 0; j < 64; j++) {
282 VAIQMatrixBufferType,
283 &iq_matrix,
sizeof(iq_matrix));
299 VASliceParameterBufferHEVC *last_slice_param = (VASliceParameterBufferHEVC *)&pic->
last_slice_param;
306 last_slice_param->LongSliceFlags.fields.LastSliceOfPic = 1;
327 VASliceParameterBufferHEVC *slice_param)
331 memset(slice_param->delta_luma_weight_l0, 0,
sizeof(slice_param->delta_luma_weight_l0));
332 memset(slice_param->delta_luma_weight_l1, 0,
sizeof(slice_param->delta_luma_weight_l1));
333 memset(slice_param->luma_offset_l0, 0,
sizeof(slice_param->luma_offset_l0));
334 memset(slice_param->luma_offset_l1, 0,
sizeof(slice_param->luma_offset_l1));
335 memset(slice_param->delta_chroma_weight_l0, 0,
sizeof(slice_param->delta_chroma_weight_l0));
336 memset(slice_param->delta_chroma_weight_l1, 0,
sizeof(slice_param->delta_chroma_weight_l1));
337 memset(slice_param->ChromaOffsetL0, 0,
sizeof(slice_param->ChromaOffsetL0));
338 memset(slice_param->ChromaOffsetL1, 0,
sizeof(slice_param->ChromaOffsetL1));
340 slice_param->delta_chroma_log2_weight_denom = 0;
341 slice_param->luma_log2_weight_denom = 0;
350 if (
h->ps.sps->chroma_format_idc) {
378 VAPictureParameterBufferHEVC *pp = (VAPictureParameterBufferHEVC *)&pic->
pic_param;
385 VASurfaceID pid = pp->ReferenceFrames[
i].picture_id;
386 int poc = pp->ReferenceFrames[
i].pic_order_cnt;
401 VASliceParameterBufferHEVC *last_slice_param = (VASliceParameterBufferHEVC *)&pic->
last_slice_param;
409 int err,
i, list_idx;
423 *last_slice_param = (VASliceParameterBufferHEVC) {
424 .slice_data_size =
size,
425 .slice_data_offset = 0,
426 .slice_data_flag = VA_SLICE_DATA_FLAG_ALL,
429 .slice_data_byte_offset = (
get_bits_count(&
h->HEVClc->gb) + 1 + 7) / 8,
435 .slice_tc_offset_div2 = sh->
tc_offset / 2,
441 .LongSliceFlags.fields = {
456 memset(last_slice_param->RefPicList, 0xFF,
sizeof(last_slice_param->RefPicList));
458 for (list_idx = 0; list_idx < nb_list; list_idx++) {
467 #if VA_CHECK_VERSION(1, 2, 0)
469 pic->last_slice_param.rext = (VASliceParameterBufferHEVCRext) {
470 .slice_ext_flags.bits = {
471 .cu_chroma_qp_offset_enabled_flag = sh->cu_chroma_qp_offset_enabled_flag,
475 memcpy(pic->last_slice_param.rext.luma_offset_l0, pic->last_slice_param.base.luma_offset_l0,
476 sizeof(pic->last_slice_param.base.luma_offset_l0));
477 memcpy(pic->last_slice_param.rext.luma_offset_l1, pic->last_slice_param.base.luma_offset_l1,
478 sizeof(pic->last_slice_param.base.luma_offset_l1));
479 memcpy(pic->last_slice_param.rext.ChromaOffsetL0, pic->last_slice_param.base.ChromaOffsetL0,
480 sizeof(pic->last_slice_param.base.ChromaOffsetL0));
481 memcpy(pic->last_slice_param.rext.ChromaOffsetL1, pic->last_slice_param.base.ChromaOffsetL1,
482 sizeof(pic->last_slice_param.base.ChromaOffsetL1));
486 pic->last_buffer =
buffer;
487 pic->last_size =
size;
501 #define copy_field(name) h265_raw_ptl->general_ ## name = general_ptl->name
546 #if VA_CHECK_VERSION(1, 2, 0)
547 if (!strcmp(
profile->name,
"Main 4:2:2 10") ||
548 !strcmp(
profile->name,
"Main 4:2:2 10 Intra"))
549 return VAProfileHEVCMain422_10;
550 else if (!strcmp(
profile->name,
"Main 4:4:4") ||
551 !strcmp(
profile->name,
"Main 4:4:4 Intra"))
552 return VAProfileHEVCMain444;
553 else if (!strcmp(
profile->name,
"Main 4:4:4 10") ||
554 !strcmp(
profile->name,
"Main 4:4:4 10 Intra"))
555 return VAProfileHEVCMain444_10;
558 "not supported with this VA version.\n",
profile->name);
564 return VAProfileHEVCMain;
566 return VAProfileNone;
570 .
name =
"hevc_vaapi",