Lines Matching +full:- +full:desc

29  * This implementation is currently based on VA-API, and other interfaces,
40 * - virgl_video_begin_frame()
44 * - virgl_video_decode_bitstream()
45 * It constructs the decoding-related VABuffers according to the picture
47 * - virgl_video_encode_bitstream()
48 * It constructs the encoding-related VABuffers according to the picture
50 * - virgl_video_end_frame()
263 return -1; in va_profile_from_pipe()
319 const VADRMPRIMESurfaceDescriptor *desc) in fill_video_dma_buf() argument
326 num_layers=%u\n", desc->fourcc, desc->width, desc->height, in fill_video_dma_buf()
327 desc->num_objects, desc->num_layers); in fill_video_dma_buf()
329 for (i = 0; i < desc->num_objects; i++) in fill_video_dma_buf()
331 i, desc->objects[i].fd, desc->objects[i].size, in fill_video_dma_buf()
332 desc->objects[i].drm_format_modifier); in fill_video_dma_buf()
334 for (i = 0; i < desc->num_layers; i++) in fill_video_dma_buf()
337 i, desc->layers[i].drm_format, desc->layers[i].num_planes, in fill_video_dma_buf()
338 desc->layers[i].object_index[0], in fill_video_dma_buf()
339 desc->layers[i].object_index[1], in fill_video_dma_buf()
340 desc->layers[i].object_index[2], in fill_video_dma_buf()
341 desc->layers[i].object_index[3], in fill_video_dma_buf()
342 desc->layers[i].offset[0], in fill_video_dma_buf()
343 desc->layers[i].offset[1], in fill_video_dma_buf()
344 desc->layers[i].offset[2], in fill_video_dma_buf()
345 desc->layers[i].offset[3], in fill_video_dma_buf()
346 desc->layers[i].pitch[0], in fill_video_dma_buf()
347 desc->layers[i].pitch[1], in fill_video_dma_buf()
348 desc->layers[i].pitch[2], in fill_video_dma_buf()
349 desc->layers[i].pitch[3]); in fill_video_dma_buf()
352 dmabuf->drm_format = drm_format_from_va_fourcc(desc->fourcc); in fill_video_dma_buf()
353 dmabuf->width = desc->width; in fill_video_dma_buf()
354 dmabuf->height = desc->height; in fill_video_dma_buf()
356 for (i = 0, dmabuf->num_planes = 0; i < desc->num_layers; i++) { in fill_video_dma_buf()
357 for (j = 0; j < desc->layers[i].num_planes && in fill_video_dma_buf()
358 dmabuf->num_planes < ARRAY_SIZE(dmabuf->planes); j++) { in fill_video_dma_buf()
360 obj_idx = desc->layers[i].object_index[j]; in fill_video_dma_buf()
361 plane = &dmabuf->planes[dmabuf->num_planes++]; in fill_video_dma_buf()
362 plane->drm_format = desc->layers[i].drm_format; in fill_video_dma_buf()
363 plane->offset = desc->layers[i].offset[j]; in fill_video_dma_buf()
364 plane->pitch = desc->layers[i].pitch[j]; in fill_video_dma_buf()
365 plane->fd = desc->objects[obj_idx].fd; in fill_video_dma_buf()
366 plane->size = desc->objects[obj_idx].size; in fill_video_dma_buf()
367 plane->modifier = desc->objects[obj_idx].drm_format_modifier; in fill_video_dma_buf()
379 VADRMPRIMESurfaceDescriptor desc; in export_video_dma_buf() local
393 va_stat = vaExportSurfaceHandle(va_dpy, buffer->va_sfc, in export_video_dma_buf()
394 VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2, exp_flags, &desc); in export_video_dma_buf()
400 fill_video_dma_buf(dmabuf, &desc); in export_video_dma_buf()
401 dmabuf->flags = flags; in export_video_dma_buf()
402 dmabuf->buf = buffer; in export_video_dma_buf()
416 for (i = 0; i < dmabuf->num_planes; i++) in destroy_video_dma_buf()
417 close(dmabuf->planes[i].fd); in destroy_video_dma_buf()
428 if (!callbacks || !callbacks->encode_upload_picture) in encode_upload_picture()
431 va_stat = vaSyncSurface(va_dpy, buffer->va_sfc); in encode_upload_picture()
437 if (!buffer->dmabuf) in encode_upload_picture()
438 buffer->dmabuf = export_video_dma_buf(buffer, VIRGL_VIDEO_DMABUF_WRITE_ONLY); in encode_upload_picture()
440 if (buffer->dmabuf) in encode_upload_picture()
441 callbacks->encode_upload_picture(codec, buffer->dmabuf); in encode_upload_picture()
453 if (!callbacks || !callbacks->encode_completed) in encode_completed()
456 va_stat = vaMapBuffer(va_dpy, codec->va_coded_buf, (void **)(&buf_list)); in encode_completed()
462 for (buf = buf_list; buf; buf = (VACodedBufferSegment *)buf->next) in encode_completed()
472 for (buf = buf_list, i = 0; buf; buf = (VACodedBufferSegment *)buf->next) { in encode_completed()
473 coded_bufs[i] = buf->buf; in encode_completed()
474 coded_sizes[i++] = buf->size; in encode_completed()
477 callbacks->encode_completed(codec, buffer->dmabuf, NULL, num_coded_bufs, in encode_completed()
481 vaUnmapBuffer(va_dpy, codec->va_coded_buf); in encode_completed()
489 if (!callbacks || !callbacks->decode_completed) in decode_completed()
492 if (!buffer->dmabuf) in decode_completed()
493 buffer->dmabuf = export_video_dma_buf(buffer, VIRGL_VIDEO_DMABUF_READ_ONLY); in decode_completed()
495 if (buffer->dmabuf) in decode_completed()
496 callbacks->decode_completed(codec, buffer->dmabuf); in decode_completed()
508 idx = frame_num % ARRAY_SIZE(codec->ref_pic_list); in get_enc_ref_pic()
510 if (!codec->ref_pic_list[idx]) { in get_enc_ref_pic()
512 args.width = codec->width; in get_enc_ref_pic()
513 args.height = codec->height; in get_enc_ref_pic()
516 codec->ref_pic_list[idx] = virgl_video_create_buffer(&args); in get_enc_ref_pic()
517 if (!codec->ref_pic_list[idx]) { in get_enc_ref_pic()
523 return codec->ref_pic_list[idx]->va_sfc; in get_enc_ref_pic()
537 return -1; in virgl_video_init()
543 return -1; in virgl_video_init()
550 return -1; in virgl_video_init()
553 virgl_log("VA-API version: %d.%d\n", major_ver, minor_ver); in virgl_video_init()
561 return -1; in virgl_video_init()
587 vcaps->profile = pipe_profile_from_va(profile); in fill_vcaps_entry()
588 vcaps->entrypoint = pipe_entrypoint_from_va(entrypoint); in fill_vcaps_entry()
589 vcaps->max_level = 0; in fill_vcaps_entry()
590 vcaps->stacked_frames = 0; in fill_vcaps_entry()
591 vcaps->max_width = 0; in fill_vcaps_entry()
592 vcaps->max_height = 0; in fill_vcaps_entry()
593 vcaps->prefered_format = PIPE_FORMAT_NONE; in fill_vcaps_entry()
594 vcaps->max_macroblocks = 1; in fill_vcaps_entry()
595 vcaps->npot_texture = 1; in fill_vcaps_entry()
596 vcaps->supports_progressive = 1; in fill_vcaps_entry()
597 vcaps->supports_interlaced = 0; in fill_vcaps_entry()
598 vcaps->prefers_interlaced = 0; in fill_vcaps_entry()
599 vcaps->max_temporal_layers = 0; in fill_vcaps_entry()
606 return -1; in fill_vcaps_entry()
612 vcaps->max_height = attrs[i].value.value.i; in fill_vcaps_entry()
615 vcaps->max_width = attrs[i].value.value.i; in fill_vcaps_entry()
618 if (PIPE_FORMAT_NONE == vcaps->prefered_format) in fill_vcaps_entry()
619 vcaps->prefered_format = \ in fill_vcaps_entry()
642 return -1; in virgl_video_fill_caps()
647 return -1; in virgl_video_fill_caps()
653 return -1; in virgl_video_fill_caps()
657 for (i = 0, caps->v2.num_video_caps = 0; i < num_profiles; i++) { in virgl_video_fill_caps()
668 caps->v2.num_video_caps < ARRAY_SIZE(caps->v2.video_caps); j++) { in virgl_video_fill_caps()
675 &caps->v2.video_caps[caps->v2.num_video_caps++]); in virgl_video_fill_caps()
700 profile = va_profile_from_pipe(args->profile); in virgl_video_create_codec()
701 entrypoint = va_entrypoint_from_pipe(args->entrypoint); in virgl_video_create_codec()
702 format = va_format_from_pipe_chroma(args->chroma_format); in virgl_video_create_codec()
723 codec->va_cfg = cfg; in virgl_video_create_codec()
725 va_stat = vaCreateContext(va_dpy, cfg, args->width, args->height, in virgl_video_create_codec()
731 codec->va_ctx = ctx; in virgl_video_create_codec()
733 codec->profile = args->profile; in virgl_video_create_codec()
734 codec->level = args->level; in virgl_video_create_codec()
735 codec->entrypoint = args->entrypoint; in virgl_video_create_codec()
736 codec->chroma_format = args->chroma_format; in virgl_video_create_codec()
737 codec->width = args->width; in virgl_video_create_codec()
738 codec->height = args->height; in virgl_video_create_codec()
739 codec->max_references = args->max_references; in virgl_video_create_codec()
740 codec->opaque = args->opaque; in virgl_video_create_codec()
743 vaCreateBuffer(va_dpy, codec->va_ctx, VAEncCodedBufferType, in virgl_video_create_codec()
744 CODED_BUF_DEFAULT_SIZE(codec->width, codec->height), in virgl_video_create_codec()
745 1, NULL, &codec->va_coded_buf); in virgl_video_create_codec()
763 if (codec->va_ctx) in virgl_video_destroy_codec()
764 vaDestroyContext(va_dpy, codec->va_ctx); in virgl_video_destroy_codec()
766 if (codec->va_cfg) in virgl_video_destroy_codec()
767 vaDestroyConfig(va_dpy, codec->va_cfg); in virgl_video_destroy_codec()
769 if (codec->va_coded_buf) in virgl_video_destroy_codec()
770 vaDestroyBuffer(va_dpy, codec->va_coded_buf); in virgl_video_destroy_codec()
772 for (i = 0; i < ARRAY_SIZE(codec->ref_pic_list); i++) { in virgl_video_destroy_codec()
773 if (codec->ref_pic_list[i]) in virgl_video_destroy_codec()
774 free(codec->ref_pic_list[i]); in virgl_video_destroy_codec()
793 * may be use va_format_from_pipe(args->format) in virgl_video_create_buffer()
797 virgl_log("pipe format %d not supported\n", args->format); in virgl_video_create_buffer()
806 args->width, args->height, &sfc, 1, NULL, 0); in virgl_video_create_buffer()
812 buffer->va_sfc = sfc; in virgl_video_create_buffer()
813 buffer->format = args->format; in virgl_video_create_buffer()
814 buffer->width = args->width; in virgl_video_create_buffer()
815 buffer->height = args->height; in virgl_video_create_buffer()
816 buffer->opaque = args->opaque; in virgl_video_create_buffer()
826 if (buffer->dmabuf) in virgl_video_destroy_buffer()
827 destroy_video_dma_buf(buffer->dmabuf); in virgl_video_destroy_buffer()
829 if (buffer->va_sfc) in virgl_video_destroy_buffer()
830 vaDestroySurfaces(va_dpy, &buffer->va_sfc, 1); in virgl_video_destroy_buffer()
837 return codec ? codec->opaque : NULL; in virgl_video_codec_opaque_data()
843 return codec ? codec->profile : PIPE_VIDEO_PROFILE_UNKNOWN; in virgl_video_codec_profile()
848 return (uint32_t)(buffer ? buffer->va_sfc : VA_INVALID_SURFACE); in virgl_video_buffer_id()
853 return buffer ? buffer->opaque : NULL; in virgl_video_buffer_opaque_data()
862 return -1; in virgl_video_begin_frame()
864 if (codec->entrypoint == PIPE_VIDEO_ENTRYPOINT_ENCODE) in virgl_video_begin_frame()
867 codec->buffer = target; in virgl_video_begin_frame()
868 va_stat = vaBeginPicture(va_dpy, codec->va_ctx, target->va_sfc); in virgl_video_begin_frame()
871 return -1; in virgl_video_begin_frame()
879 (dest)->member = (src)->member
882 memcpy(&(dest)->member, &(src)->member, sizeof((dest)->member))
887 pic->picture_id = VA_INVALID_SURFACE; in h264_init_picture()
888 pic->frame_idx = 0; in h264_init_picture()
889 pic->flags = VA_PICTURE_H264_INVALID; in h264_init_picture()
890 pic->TopFieldOrderCnt = 0; in h264_init_picture()
891 pic->BottomFieldOrderCnt = 0; in h264_init_picture()
900 const struct virgl_h264_picture_desc *desc, in h264_fill_picture_param() argument
909 pic = &vapp->CurrPic; in h264_fill_picture_param()
910 pic->picture_id = target->va_sfc; in h264_fill_picture_param()
911 pic->frame_idx = desc->frame_num; in h264_fill_picture_param()
912 pic->flags = desc->is_reference ? VA_PICTURE_H264_SHORT_TERM_REFERENCE : 0; in h264_fill_picture_param()
913 if (desc->field_pic_flag) in h264_fill_picture_param()
914 pic->flags |= (desc->bottom_field_flag ? VA_PICTURE_H264_BOTTOM_FIELD in h264_fill_picture_param()
916 pic->TopFieldOrderCnt = desc->field_order_cnt[0]; in h264_fill_picture_param()
917 pic->BottomFieldOrderCnt = desc->field_order_cnt[1]; in h264_fill_picture_param()
921 for (i = 0; i < ARRAY_SIZE(vapp->ReferenceFrames); i++) in h264_fill_picture_param()
922 h264_init_picture(&vapp->ReferenceFrames[i]); in h264_fill_picture_param()
924 for (i = 0; i < desc->num_ref_frames; i++) { in h264_fill_picture_param()
925 pic = &vapp->ReferenceFrames[i]; in h264_fill_picture_param()
927 pic->picture_id = desc->buffer_id[i]; in h264_fill_picture_param()
928 pic->frame_idx = desc->frame_num_list[i]; in h264_fill_picture_param()
929 pic->flags = (desc->is_long_term[i] in h264_fill_picture_param()
932 if (desc->top_is_reference[i] && desc->bottom_is_reference[i]) { in h264_fill_picture_param()
935 if (desc->top_is_reference[i]) in h264_fill_picture_param()
936 pic->flags |= VA_PICTURE_H264_TOP_FIELD; in h264_fill_picture_param()
938 pic->flags |= VA_PICTURE_H264_BOTTOM_FIELD; in h264_fill_picture_param()
940 pic->TopFieldOrderCnt = desc->field_order_cnt_list[i][0]; in h264_fill_picture_param()
941 pic->BottomFieldOrderCnt = desc->field_order_cnt_list[i][1]; in h264_fill_picture_param()
944 //vapp->picture_width_in_mbs_minus1 = (codec->width - 1) / 16; in h264_fill_picture_param()
945 //vapp->picture_height_in_mbs_minus1 = (codec->height - 1) / 16; in h264_fill_picture_param()
946 ITEM_SET(vapp, &desc->pps.sps, bit_depth_luma_minus8); in h264_fill_picture_param()
947 ITEM_SET(vapp, &desc->pps.sps, bit_depth_chroma_minus8); in h264_fill_picture_param()
948 ITEM_SET(vapp, desc, num_ref_frames); in h264_fill_picture_param()
950 ITEM_SET(&vapp->seq_fields.bits, &desc->pps.sps, chroma_format_idc); in h264_fill_picture_param()
951 //vapp->seq_fields.bits.residual_colour_transform_flag = 0; in h264_fill_picture_param()
952 //vapp->seq_fields.bits.gaps_in_frame_num_value_allowed_flag = 0; in h264_fill_picture_param()
953 ITEM_SET(&vapp->seq_fields.bits, &desc->pps.sps, frame_mbs_only_flag); in h264_fill_picture_param()
954 ITEM_SET(&vapp->seq_fields.bits, in h264_fill_picture_param()
955 &desc->pps.sps, mb_adaptive_frame_field_flag); in h264_fill_picture_param()
956 ITEM_SET(&vapp->seq_fields.bits, &desc->pps.sps, direct_8x8_inference_flag); in h264_fill_picture_param()
957 ITEM_SET(&vapp->seq_fields.bits, &desc->pps.sps, MinLumaBiPredSize8x8); in h264_fill_picture_param()
958 ITEM_SET(&vapp->seq_fields.bits, &desc->pps.sps, log2_max_frame_num_minus4); in h264_fill_picture_param()
959 ITEM_SET(&vapp->seq_fields.bits, &desc->pps.sps, pic_order_cnt_type); in h264_fill_picture_param()
960 ITEM_SET(&vapp->seq_fields.bits, in h264_fill_picture_param()
961 &desc->pps.sps, log2_max_pic_order_cnt_lsb_minus4); in h264_fill_picture_param()
962 ITEM_SET(&vapp->seq_fields.bits, in h264_fill_picture_param()
963 &desc->pps.sps, delta_pic_order_always_zero_flag); in h264_fill_picture_param()
965 //ITEM_SET(vapp, &desc->pps, num_slice_groups_minus1); in h264_fill_picture_param()
966 //ITEM_SET(vapp, &desc->pps, slice_group_map_type); in h264_fill_picture_param()
967 //ITEM_SET(vapp, &desc->pps, slice_group_change_rate_minus1); in h264_fill_picture_param()
968 ITEM_SET(vapp, &desc->pps, pic_init_qp_minus26); in h264_fill_picture_param()
969 ITEM_SET(vapp, &desc->pps, pic_init_qs_minus26); in h264_fill_picture_param()
970 ITEM_SET(vapp, &desc->pps, chroma_qp_index_offset); in h264_fill_picture_param()
971 ITEM_SET(vapp, &desc->pps, second_chroma_qp_index_offset); in h264_fill_picture_param()
973 ITEM_SET(&vapp->pic_fields.bits, &desc->pps, entropy_coding_mode_flag); in h264_fill_picture_param()
974 ITEM_SET(&vapp->pic_fields.bits, &desc->pps, weighted_pred_flag); in h264_fill_picture_param()
975 ITEM_SET(&vapp->pic_fields.bits, &desc->pps, weighted_bipred_idc); in h264_fill_picture_param()
976 ITEM_SET(&vapp->pic_fields.bits, &desc->pps, transform_8x8_mode_flag); in h264_fill_picture_param()
977 ITEM_SET(&vapp->pic_fields.bits, desc, field_pic_flag); in h264_fill_picture_param()
978 ITEM_SET(&vapp->pic_fields.bits, &desc->pps, constrained_intra_pred_flag); in h264_fill_picture_param()
979 vapp->pic_fields.bits.pic_order_present_flag = in h264_fill_picture_param()
980 desc->pps.bottom_field_pic_order_in_frame_present_flag; in h264_fill_picture_param()
981 ITEM_SET(&vapp->pic_fields.bits, in h264_fill_picture_param()
982 &desc->pps, deblocking_filter_control_present_flag); in h264_fill_picture_param()
983 ITEM_SET(&vapp->pic_fields.bits, in h264_fill_picture_param()
984 &desc->pps, redundant_pic_cnt_present_flag); in h264_fill_picture_param()
985 vapp->pic_fields.bits.reference_pic_flag = desc->is_reference; in h264_fill_picture_param()
987 ITEM_SET(vapp, desc, frame_num); in h264_fill_picture_param()
992 static void h264_fill_iq_matrix(const struct virgl_h264_picture_desc *desc, in h264_fill_iq_matrix() argument
995 ITEM_CPY(vaiqm, &desc->pps, ScalingList4x4); in h264_fill_iq_matrix()
996 ITEM_CPY(vaiqm, &desc->pps, ScalingList8x8); in h264_fill_iq_matrix()
1003 static void h264_fill_slice_param(const struct virgl_h264_picture_desc *desc, in h264_fill_slice_param() argument
1006 //vasp->slice_data_size; in h264_fill_slice_param()
1007 //vasp->slice_data_offset; in h264_fill_slice_param()
1008 //vasp->slice_data_flag; in h264_fill_slice_param()
1009 //vasp->slice_data_bit_offset; in h264_fill_slice_param()
1010 //vasp->first_mb_in_slice; in h264_fill_slice_param()
1011 //vasp->slice_type; in h264_fill_slice_param()
1012 //vasp->direct_spatial_mv_pred_flag; in h264_fill_slice_param()
1013 ITEM_SET(vasp, desc, num_ref_idx_l0_active_minus1); in h264_fill_slice_param()
1014 ITEM_SET(vasp, desc, num_ref_idx_l1_active_minus1); in h264_fill_slice_param()
1015 //vasp->cabac_init_idc; in h264_fill_slice_param()
1016 //vasp->slice_qp_delta; in h264_fill_slice_param()
1017 //vasp->disable_deblocking_filter_idc; in h264_fill_slice_param()
1018 //vasp->slice_alpha_c0_offset_div2; in h264_fill_slice_param()
1019 //vasp->slice_beta_offset_div2; in h264_fill_slice_param()
1020 //vasp->RefPicList0[32]; in h264_fill_slice_param()
1021 //vasp->RefPicList1[32]; in h264_fill_slice_param()
1024 //vasp->luma_log2_weight_denom; in h264_fill_slice_param()
1025 //vasp->chroma_log2_weight_denom; in h264_fill_slice_param()
1026 //vasp->luma_weight_l0_flag; in h264_fill_slice_param()
1027 //vasp->luma_weight_l0[32]; in h264_fill_slice_param()
1028 //vasp->luma_offset_l0[32]; in h264_fill_slice_param()
1029 //vasp->chroma_weight_l0_flag; in h264_fill_slice_param()
1030 //vasp->chroma_weight_l0[32][2]; in h264_fill_slice_param()
1031 //vasp->chroma_offset_l0[32][2]; in h264_fill_slice_param()
1032 //vasp->luma_weight_l1_flag; in h264_fill_slice_param()
1033 //vasp->luma_weight_l1[32]; in h264_fill_slice_param()
1034 //vasp->luma_offset_l1[32]; in h264_fill_slice_param()
1035 //vasp->chroma_weight_l1_flag; in h264_fill_slice_param()
1036 //vasp->chroma_weight_l1[32][2]; in h264_fill_slice_param()
1037 //vasp->chroma_offset_l1[32][2]; in h264_fill_slice_param()
1047 const struct virgl_h264_enc_picture_desc *desc, in h264_fill_enc_picture_param() argument
1056 param->CurrPic.picture_id = get_enc_ref_pic(codec, desc->frame_num); in h264_fill_enc_picture_param()
1059 param->CurrPic.TopFieldOrderCnt = desc->pic_order_cnt; in h264_fill_enc_picture_param()
1063 for (i = 0; i < ARRAY_SIZE(param->ReferenceFrames); i++) in h264_fill_enc_picture_param()
1064 h264_init_picture(&param->ReferenceFrames[i]); in h264_fill_enc_picture_param()
1067 param->coded_buf = codec->va_coded_buf; in h264_fill_enc_picture_param()
1073 param->pic_init_qp = desc->quant_i_frames; in h264_fill_enc_picture_param()
1074 param->num_ref_idx_l0_active_minus1 = desc->num_ref_idx_l0_active_minus1; in h264_fill_enc_picture_param()
1075 param->num_ref_idx_l1_active_minus1 = desc->num_ref_idx_l1_active_minus1; in h264_fill_enc_picture_param()
1080 param->pic_fields.bits.idr_pic_flag = in h264_fill_enc_picture_param()
1081 (desc->picture_type == PIPE_H2645_ENC_PICTURE_TYPE_IDR); in h264_fill_enc_picture_param()
1082 param->pic_fields.bits.reference_pic_flag = !desc->not_referenced; in h264_fill_enc_picture_param()
1083 param->pic_fields.bits.entropy_coding_mode_flag = desc->pic_ctrl.enc_cabac_enable; in h264_fill_enc_picture_param()
1102 const struct virgl_h264_enc_picture_desc *desc, in h264_fill_enc_slice_param() argument
1112 if (desc->num_slice_descriptors && in h264_fill_enc_slice_param()
1113 desc->num_slice_descriptors <= ARRAY_SIZE(desc->slices_descriptors)) { in h264_fill_enc_slice_param()
1114 sd = &desc->slices_descriptors[desc->num_slice_descriptors - 1]; in h264_fill_enc_slice_param()
1115 param->macroblock_address = sd->macroblock_address; in h264_fill_enc_slice_param()
1116 param->num_macroblocks = sd->num_macroblocks; in h264_fill_enc_slice_param()
1120 switch (desc->picture_type) { in h264_fill_enc_slice_param()
1122 param->slice_type = 0; in h264_fill_enc_slice_param()
1125 param->slice_type = 1; in h264_fill_enc_slice_param()
1129 param->slice_type = 2; in h264_fill_enc_slice_param()
1148 param->num_ref_idx_active_override_flag = 0; in h264_fill_enc_slice_param()
1154 h264_init_picture(&param->RefPicList0[i]); in h264_fill_enc_slice_param()
1155 h264_init_picture(&param->RefPicList1[i]); in h264_fill_enc_slice_param()
1157 param->RefPicList0[i].picture_id = in h264_fill_enc_slice_param()
1158 get_enc_ref_pic(codec, desc->ref_idx_l0_list[i]); in h264_fill_enc_slice_param()
1159 param->RefPicList1[i].picture_id = in h264_fill_enc_slice_param()
1160 get_enc_ref_pic(codec, desc->ref_idx_l1_list[i]); in h264_fill_enc_slice_param()
1162 if (param->RefPicList0[i].picture_id != VA_INVALID_ID) in h264_fill_enc_slice_param()
1163 param->RefPicList0[i].flags = VA_PICTURE_H264_SHORT_TERM_REFERENCE; in h264_fill_enc_slice_param()
1165 if (param->RefPicList1[i].picture_id != VA_INVALID_ID) in h264_fill_enc_slice_param()
1166 param->RefPicList1[i].flags = VA_PICTURE_H264_SHORT_TERM_REFERENCE; in h264_fill_enc_slice_param()
1183 param->cabac_init_idc = desc->pic_ctrl.enc_cabac_init_idc; in h264_fill_enc_slice_param()
1198 const struct virgl_h264_enc_picture_desc *desc, in h264_fill_enc_seq_param() argument
1205 param->level_idc = codec->level; in h264_fill_enc_seq_param()
1207 param->intra_idr_period = desc->intra_idr_period; in h264_fill_enc_seq_param()
1210 param->max_num_ref_frames = codec->max_references; in h264_fill_enc_seq_param()
1221 ITEM_SET(&param->seq_fields.bits, &desc->seq, pic_order_cnt_type); in h264_fill_enc_seq_param()
1232 if (desc->seq.enc_frame_cropping_flag) { in h264_fill_enc_seq_param()
1233 param->frame_cropping_flag = desc->seq.enc_frame_cropping_flag; in h264_fill_enc_seq_param()
1234 param->frame_crop_left_offset = desc->seq.enc_frame_crop_left_offset; in h264_fill_enc_seq_param()
1235 param->frame_crop_right_offset = desc->seq.enc_frame_crop_right_offset; in h264_fill_enc_seq_param()
1236 param->frame_crop_top_offset = desc->seq.enc_frame_crop_top_offset; in h264_fill_enc_seq_param()
1237 param->frame_crop_bottom_offset = desc->seq.enc_frame_crop_bottom_offset; in h264_fill_enc_seq_param()
1240 ITEM_SET(param, &desc->seq, vui_parameters_present_flag); in h264_fill_enc_seq_param()
1243 if (desc->seq.vui_parameters_present_flag) { in h264_fill_enc_seq_param()
1244 ITEM_SET(&param->vui_fields.bits, &desc->seq.vui_flags, in h264_fill_enc_seq_param()
1246 ITEM_SET(&param->vui_fields.bits, &desc->seq.vui_flags, in h264_fill_enc_seq_param()
1256 if (desc->seq.vui_parameters_present_flag) { in h264_fill_enc_seq_param()
1257 ITEM_SET(param, &desc->seq, aspect_ratio_idc); in h264_fill_enc_seq_param()
1258 ITEM_SET(param, &desc->seq, sar_width); in h264_fill_enc_seq_param()
1259 ITEM_SET(param, &desc->seq, sar_height); in h264_fill_enc_seq_param()
1261 ITEM_SET(param, &desc->seq, num_units_in_tick); in h264_fill_enc_seq_param()
1262 ITEM_SET(param, &desc->seq, time_scale); in h264_fill_enc_seq_param()
1272 const struct virgl_h264_enc_picture_desc *desc, in h264_fill_enc_misc_param_rate_ctrl() argument
1276 const struct virgl_h264_enc_rate_control *rc = &desc->rate_ctrl[temporal_id]; in h264_fill_enc_misc_param_rate_ctrl()
1281 param->bits_per_second = rc->peak_bitrate; in h264_fill_enc_misc_param_rate_ctrl()
1282 if (desc->rate_ctrl[0].rate_ctrl_method != in h264_fill_enc_misc_param_rate_ctrl()
1284 param->target_percentage = rc->target_bitrate * in h264_fill_enc_misc_param_rate_ctrl()
1285 param->bits_per_second / 100.0; in h264_fill_enc_misc_param_rate_ctrl()
1289 param->min_qp = rc->min_qp; in h264_fill_enc_misc_param_rate_ctrl()
1294 param->rc_flags.bits.disable_frame_skip = !rc->skip_frame_enable; in h264_fill_enc_misc_param_rate_ctrl()
1295 param->rc_flags.bits.disable_bit_stuffing = !rc->fill_data_enable; in h264_fill_enc_misc_param_rate_ctrl()
1297 param->rc_flags.bits.temporal_id = temporal_id; in h264_fill_enc_misc_param_rate_ctrl()
1304 param->max_qp = rc->max_qp; in h264_fill_enc_misc_param_rate_ctrl()
1316 const struct virgl_h264_enc_picture_desc *desc, in h264_fill_enc_misc_param_frame_rate() argument
1320 const struct virgl_h264_enc_rate_control *rc = &desc->rate_ctrl[temporal_id]; in h264_fill_enc_misc_param_frame_rate()
1325 param->framerate = rc->frame_rate_num | (rc->frame_rate_den << 16); in h264_fill_enc_misc_param_frame_rate()
1326 param->framerate_flags.bits.temporal_id = temporal_id; in h264_fill_enc_misc_param_frame_rate()
1331 const struct virgl_h264_picture_desc *desc, in h264_decode_bitstream() argument
1347 return -1; in h264_decode_bitstream()
1350 h264_fill_picture_param(codec, target, desc, &pic_param); in h264_decode_bitstream()
1351 vaCreateBuffer(va_dpy, codec->va_ctx, VAPictureParameterBufferType, in h264_decode_bitstream()
1354 h264_fill_iq_matrix(desc, &iq_matrix); in h264_decode_bitstream()
1355 vaCreateBuffer(va_dpy, codec->va_ctx, VAIQMatrixBufferType, in h264_decode_bitstream()
1358 h264_fill_slice_param(desc, &slice_param); in h264_decode_bitstream()
1359 vaCreateBuffer(va_dpy, codec->va_ctx, VASliceParameterBufferType, in h264_decode_bitstream()
1363 vaCreateBuffer(va_dpy, codec->va_ctx, VASliceDataBufferType, in h264_decode_bitstream()
1367 va_stat = vaRenderPicture(va_dpy, codec->va_ctx, &pic_param_buf, 1); in h264_decode_bitstream()
1370 err = -1; in h264_decode_bitstream()
1374 va_stat = vaRenderPicture(va_dpy, codec->va_ctx, &iq_matrix_buf, 1); in h264_decode_bitstream()
1377 err = -1; in h264_decode_bitstream()
1381 va_stat = vaRenderPicture(va_dpy, codec->va_ctx, &slice_param_buf, 1); in h264_decode_bitstream()
1384 err = -1; in h264_decode_bitstream()
1389 va_stat = vaRenderPicture(va_dpy, codec->va_ctx, &slice_data_buf[i], 1); in h264_decode_bitstream()
1393 err = -1; in h264_decode_bitstream()
1411 const struct virgl_h264_enc_picture_desc *desc) in h264_encode_render_sequence() argument
1420 h264_fill_enc_seq_param(codec, source, desc, &seq_param); in h264_encode_render_sequence()
1421 vaCreateBuffer(va_dpy, codec->va_ctx, VAEncSequenceParameterBufferType, in h264_encode_render_sequence()
1424 vaCreateBuffer(va_dpy, codec->va_ctx, VAEncMiscParameterBufferType, in h264_encode_render_sequence()
1428 misc_param->type = VAEncMiscParameterTypeRateControl; in h264_encode_render_sequence()
1429 h264_fill_enc_misc_param_rate_ctrl(codec, source, desc, in h264_encode_render_sequence()
1430 (VAEncMiscParameterRateControl *)misc_param->data); in h264_encode_render_sequence()
1433 vaCreateBuffer(va_dpy, codec->va_ctx, VAEncMiscParameterBufferType, in h264_encode_render_sequence()
1437 misc_param->type = VAEncMiscParameterTypeFrameRate; in h264_encode_render_sequence()
1438 h264_fill_enc_misc_param_frame_rate(codec, source, desc, in h264_encode_render_sequence()
1439 (VAEncMiscParameterFrameRate *)misc_param->data); in h264_encode_render_sequence()
1442 va_stat = vaRenderPicture(va_dpy, codec->va_ctx, &seq_param_buf, 1); in h264_encode_render_sequence()
1445 err = -1; in h264_encode_render_sequence()
1449 va_stat = vaRenderPicture(va_dpy, codec->va_ctx, &rc_param_buf, 1); in h264_encode_render_sequence()
1452 err = -1; in h264_encode_render_sequence()
1456 va_stat = vaRenderPicture(va_dpy, codec->va_ctx, &fr_param_buf, 1); in h264_encode_render_sequence()
1459 err = -1; in h264_encode_render_sequence()
1474 const struct virgl_h264_enc_picture_desc *desc) in h264_encode_render_picture() argument
1481 h264_fill_enc_picture_param(codec, source, desc, &pic_param); in h264_encode_render_picture()
1482 vaCreateBuffer(va_dpy, codec->va_ctx, VAEncPictureParameterBufferType, in h264_encode_render_picture()
1485 va_stat = vaRenderPicture(va_dpy, codec->va_ctx, &pic_param_buf, 1); in h264_encode_render_picture()
1490 return -1; in h264_encode_render_picture()
1499 const struct virgl_h264_enc_picture_desc *desc) in h264_encode_render_slice() argument
1506 h264_fill_enc_slice_param(codec, source, desc, &slice_param); in h264_encode_render_slice()
1507 vaCreateBuffer(va_dpy, codec->va_ctx, VAEncSliceParameterBufferType, in h264_encode_render_slice()
1510 va_stat = vaRenderPicture(va_dpy, codec->va_ctx, &slice_param_buf, 1); in h264_encode_render_slice()
1515 return -1; in h264_encode_render_slice()
1524 const struct virgl_h264_enc_picture_desc *desc) in h264_encode_bitstream() argument
1526 if (desc->picture_type == PIPE_H2645_ENC_PICTURE_TYPE_IDR) { in h264_encode_bitstream()
1527 h264_encode_render_sequence(codec, source, desc); in h264_encode_bitstream()
1530 h264_encode_render_picture(codec, source, desc); in h264_encode_bitstream()
1531 h264_encode_render_slice(codec, source, desc); in h264_encode_bitstream()
1538 pic->picture_id = VA_INVALID_SURFACE; in h265_init_picture()
1539 pic->pic_order_cnt = 0; in h265_init_picture()
1540 pic->flags = VA_PICTURE_HEVC_INVALID; in h265_init_picture()
1549 const struct virgl_h265_picture_desc *desc, in h265_fill_picture_param() argument
1557 //vapp->CurrPic.picture_id in h265_fill_picture_param()
1558 vapp->CurrPic.pic_order_cnt = desc->CurrPicOrderCntVal; in h265_fill_picture_param()
1559 //vapp->CurrPic.flags in h265_fill_picture_param()
1562 vapp->ReferenceFrames[i].pic_order_cnt = desc->PicOrderCntVal[i]; in h265_fill_picture_param()
1563 vapp->ReferenceFrames[i].picture_id = desc->ref[i]; in h265_fill_picture_param()
1564 vapp->ReferenceFrames[i].flags = VA_INVALID_SURFACE == desc->ref[i] in h265_fill_picture_param()
1567 for (i = 0; i < desc->NumPocStCurrBefore; i++) in h265_fill_picture_param()
1568 vapp->ReferenceFrames[desc->RefPicSetStCurrBefore[i]].flags |= \ in h265_fill_picture_param()
1570 for (i = 0; i < desc->NumPocStCurrAfter; i++) in h265_fill_picture_param()
1571 vapp->ReferenceFrames[desc->RefPicSetStCurrAfter[i]].flags |= \ in h265_fill_picture_param()
1573 for (i = 0; i < desc->NumPocLtCurr; i++) in h265_fill_picture_param()
1574 vapp->ReferenceFrames[desc->RefPicSetLtCurr[i]].flags |= \ in h265_fill_picture_param()
1577 ITEM_SET(vapp, &desc->pps.sps, pic_width_in_luma_samples); in h265_fill_picture_param()
1578 ITEM_SET(vapp, &desc->pps.sps, pic_height_in_luma_samples); in h265_fill_picture_param()
1580 ITEM_SET(&vapp->pic_fields.bits, &desc->pps.sps, chroma_format_idc); in h265_fill_picture_param()
1581 ITEM_SET(&vapp->pic_fields.bits, in h265_fill_picture_param()
1582 &desc->pps.sps, separate_colour_plane_flag); in h265_fill_picture_param()
1583 ITEM_SET(&vapp->pic_fields.bits, &desc->pps.sps, pcm_enabled_flag); in h265_fill_picture_param()
1584 ITEM_SET(&vapp->pic_fields.bits, in h265_fill_picture_param()
1585 &desc->pps.sps, scaling_list_enabled_flag); in h265_fill_picture_param()
1586 ITEM_SET(&vapp->pic_fields.bits, in h265_fill_picture_param()
1587 &desc->pps, transform_skip_enabled_flag); in h265_fill_picture_param()
1588 ITEM_SET(&vapp->pic_fields.bits, &desc->pps.sps, amp_enabled_flag); in h265_fill_picture_param()
1589 ITEM_SET(&vapp->pic_fields.bits, in h265_fill_picture_param()
1590 &desc->pps.sps, strong_intra_smoothing_enabled_flag); in h265_fill_picture_param()
1591 ITEM_SET(&vapp->pic_fields.bits, &desc->pps, sign_data_hiding_enabled_flag); in h265_fill_picture_param()
1592 ITEM_SET(&vapp->pic_fields.bits, &desc->pps, constrained_intra_pred_flag); in h265_fill_picture_param()
1593 ITEM_SET(&vapp->pic_fields.bits, &desc->pps, cu_qp_delta_enabled_flag); in h265_fill_picture_param()
1594 ITEM_SET(&vapp->pic_fields.bits, &desc->pps, weighted_pred_flag); in h265_fill_picture_param()
1595 ITEM_SET(&vapp->pic_fields.bits, &desc->pps, weighted_bipred_flag); in h265_fill_picture_param()
1596 ITEM_SET(&vapp->pic_fields.bits, in h265_fill_picture_param()
1597 &desc->pps, transquant_bypass_enabled_flag); in h265_fill_picture_param()
1598 ITEM_SET(&vapp->pic_fields.bits, &desc->pps, tiles_enabled_flag); in h265_fill_picture_param()
1599 ITEM_SET(&vapp->pic_fields.bits, in h265_fill_picture_param()
1600 &desc->pps, entropy_coding_sync_enabled_flag); in h265_fill_picture_param()
1601 ITEM_SET(&vapp->pic_fields.bits, &desc->pps, in h265_fill_picture_param()
1603 if (desc->pps.tiles_enabled_flag) in h265_fill_picture_param()
1604 ITEM_SET(&vapp->pic_fields.bits, in h265_fill_picture_param()
1605 &desc->pps, loop_filter_across_tiles_enabled_flag); in h265_fill_picture_param()
1606 if (desc->pps.sps.pcm_enabled_flag) in h265_fill_picture_param()
1607 ITEM_SET(&vapp->pic_fields.bits, in h265_fill_picture_param()
1608 &desc->pps.sps, pcm_loop_filter_disabled_flag); in h265_fill_picture_param()
1609 //ITEM_SET(vapp->pic_fields.bits, desc->pps.sps, NoPicReorderingFlag); in h265_fill_picture_param()
1610 //ITEM_SET(vapp->pic_fields.bits, desc->pps.sps, NoBiPredFlag); in h265_fill_picture_param()
1612 ITEM_SET(vapp, &desc->pps.sps, sps_max_dec_pic_buffering_minus1); in h265_fill_picture_param()
1613 ITEM_SET(vapp, &desc->pps.sps, bit_depth_luma_minus8); in h265_fill_picture_param()
1614 ITEM_SET(vapp, &desc->pps.sps, bit_depth_chroma_minus8); in h265_fill_picture_param()
1615 if (desc->pps.sps.pcm_enabled_flag) { in h265_fill_picture_param()
1616 ITEM_SET(vapp, &desc->pps.sps, pcm_sample_bit_depth_luma_minus1); in h265_fill_picture_param()
1617 ITEM_SET(vapp, &desc->pps.sps, pcm_sample_bit_depth_chroma_minus1); in h265_fill_picture_param()
1619 ITEM_SET(vapp, &desc->pps.sps, log2_min_luma_coding_block_size_minus3); in h265_fill_picture_param()
1620 ITEM_SET(vapp, &desc->pps.sps, log2_diff_max_min_luma_coding_block_size); in h265_fill_picture_param()
1621 ITEM_SET(vapp, &desc->pps.sps, log2_min_transform_block_size_minus2); in h265_fill_picture_param()
1622 ITEM_SET(vapp, &desc->pps.sps, log2_diff_max_min_transform_block_size); in h265_fill_picture_param()
1623 if (desc->pps.sps.pcm_enabled_flag) { in h265_fill_picture_param()
1624 ITEM_SET(vapp, &desc->pps.sps, in h265_fill_picture_param()
1626 ITEM_SET(vapp, &desc->pps.sps, in h265_fill_picture_param()
1629 ITEM_SET(vapp, &desc->pps.sps, max_transform_hierarchy_depth_intra); in h265_fill_picture_param()
1630 ITEM_SET(vapp, &desc->pps.sps, max_transform_hierarchy_depth_inter); in h265_fill_picture_param()
1631 ITEM_SET(vapp, &desc->pps, init_qp_minus26); in h265_fill_picture_param()
1632 ITEM_SET(vapp, &desc->pps, diff_cu_qp_delta_depth); in h265_fill_picture_param()
1633 ITEM_SET(vapp, &desc->pps, pps_cb_qp_offset); in h265_fill_picture_param()
1634 ITEM_SET(vapp, &desc->pps, pps_cr_qp_offset); in h265_fill_picture_param()
1635 ITEM_SET(vapp, &desc->pps, log2_parallel_merge_level_minus2); in h265_fill_picture_param()
1636 if (desc->pps.tiles_enabled_flag) { in h265_fill_picture_param()
1637 ITEM_SET(vapp, &desc->pps, num_tile_columns_minus1); in h265_fill_picture_param()
1638 ITEM_SET(vapp, &desc->pps, num_tile_rows_minus1); in h265_fill_picture_param()
1639 ITEM_CPY(vapp, &desc->pps, column_width_minus1); in h265_fill_picture_param()
1640 ITEM_CPY(vapp, &desc->pps, row_height_minus1); in h265_fill_picture_param()
1643 ITEM_SET(&vapp->slice_parsing_fields.bits, in h265_fill_picture_param()
1644 &desc->pps, lists_modification_present_flag); in h265_fill_picture_param()
1645 ITEM_SET(&vapp->slice_parsing_fields.bits, in h265_fill_picture_param()
1646 &desc->pps.sps, long_term_ref_pics_present_flag); in h265_fill_picture_param()
1647 ITEM_SET(&vapp->slice_parsing_fields.bits, in h265_fill_picture_param()
1648 &desc->pps.sps, sps_temporal_mvp_enabled_flag); in h265_fill_picture_param()
1649 ITEM_SET(&vapp->slice_parsing_fields.bits, in h265_fill_picture_param()
1650 &desc->pps, cabac_init_present_flag); in h265_fill_picture_param()
1651 ITEM_SET(&vapp->slice_parsing_fields.bits, in h265_fill_picture_param()
1652 &desc->pps, output_flag_present_flag); in h265_fill_picture_param()
1653 ITEM_SET(&vapp->slice_parsing_fields.bits, in h265_fill_picture_param()
1654 &desc->pps, dependent_slice_segments_enabled_flag); in h265_fill_picture_param()
1655 ITEM_SET(&vapp->slice_parsing_fields.bits, in h265_fill_picture_param()
1656 &desc->pps, pps_slice_chroma_qp_offsets_present_flag); in h265_fill_picture_param()
1657 ITEM_SET(&vapp->slice_parsing_fields.bits, in h265_fill_picture_param()
1658 &desc->pps.sps, sample_adaptive_offset_enabled_flag); in h265_fill_picture_param()
1659 ITEM_SET(&vapp->slice_parsing_fields.bits, in h265_fill_picture_param()
1660 &desc->pps, deblocking_filter_override_enabled_flag); in h265_fill_picture_param()
1661 vapp->slice_parsing_fields.bits.pps_disable_deblocking_filter_flag = \ in h265_fill_picture_param()
1662 desc->pps.pps_deblocking_filter_disabled_flag; in h265_fill_picture_param()
1663 ITEM_SET(&vapp->slice_parsing_fields.bits, in h265_fill_picture_param()
1664 &desc->pps, slice_segment_header_extension_present_flag); in h265_fill_picture_param()
1665 vapp->slice_parsing_fields.bits.RapPicFlag = desc->RAPPicFlag; in h265_fill_picture_param()
1666 vapp->slice_parsing_fields.bits.IdrPicFlag = desc->IDRPicFlag; in h265_fill_picture_param()
1667 //vapp->slice_parsing_fields.bits.IntraPicFlag in h265_fill_picture_param()
1669 ITEM_SET(vapp, &desc->pps.sps, log2_max_pic_order_cnt_lsb_minus4); in h265_fill_picture_param()
1670 ITEM_SET(vapp, &desc->pps.sps, num_short_term_ref_pic_sets); in h265_fill_picture_param()
1671 vapp->num_long_term_ref_pic_sps = desc->pps.sps.num_long_term_ref_pics_sps; in h265_fill_picture_param()
1672 ITEM_SET(vapp, &desc->pps, num_ref_idx_l0_default_active_minus1); in h265_fill_picture_param()
1673 ITEM_SET(vapp, &desc->pps, num_ref_idx_l1_default_active_minus1); in h265_fill_picture_param()
1674 ITEM_SET(vapp, &desc->pps, pps_beta_offset_div2); in h265_fill_picture_param()
1675 ITEM_SET(vapp, &desc->pps, pps_tc_offset_div2); in h265_fill_picture_param()
1676 ITEM_SET(vapp, &desc->pps, num_extra_slice_header_bits); in h265_fill_picture_param()
1678 ITEM_SET(vapp, &desc->pps, st_rps_bits); in h265_fill_picture_param()
1685 static void h265_fill_slice_param(const struct virgl_h265_picture_desc *desc, in h265_fill_slice_param() argument
1697 vapp->RefPicList[i][j] = desc->RefPicList[i][j]; in h265_fill_slice_param()
1722 //va_reserved[VA_PADDING_LOW - 2]; in h265_fill_slice_param()
1732 const struct virgl_h265_enc_picture_desc *desc, in h265_fill_enc_seq_param() argument
1738 ITEM_SET(param, &desc->seq, general_profile_idc); in h265_fill_enc_seq_param()
1739 ITEM_SET(param, &desc->seq, general_level_idc); in h265_fill_enc_seq_param()
1740 ITEM_SET(param, &desc->seq, general_tier_flag); in h265_fill_enc_seq_param()
1741 ITEM_SET(param, &desc->seq, intra_period); in h265_fill_enc_seq_param()
1743 ITEM_SET(param, &desc->seq, ip_period); in h265_fill_enc_seq_param()
1745 ITEM_SET(param, &desc->seq, pic_width_in_luma_samples); in h265_fill_enc_seq_param()
1746 ITEM_SET(param, &desc->seq, pic_height_in_luma_samples); in h265_fill_enc_seq_param()
1749 ITEM_SET(&param->seq_fields.bits, &desc->seq, chroma_format_idc); in h265_fill_enc_seq_param()
1751 ITEM_SET(&param->seq_fields.bits, &desc->seq, bit_depth_luma_minus8); in h265_fill_enc_seq_param()
1752 ITEM_SET(&param->seq_fields.bits, &desc->seq, bit_depth_chroma_minus8); in h265_fill_enc_seq_param()
1754 ITEM_SET(&param->seq_fields.bits, &desc->seq, strong_intra_smoothing_enabled_flag); in h265_fill_enc_seq_param()
1755 ITEM_SET(&param->seq_fields.bits, &desc->seq, amp_enabled_flag); in h265_fill_enc_seq_param()
1756 ITEM_SET(&param->seq_fields.bits, &desc->seq, sample_adaptive_offset_enabled_flag); in h265_fill_enc_seq_param()
1757 ITEM_SET(&param->seq_fields.bits, &desc->seq, pcm_enabled_flag); in h265_fill_enc_seq_param()
1759 ITEM_SET(&param->seq_fields.bits, &desc->seq, sps_temporal_mvp_enabled_flag); in h265_fill_enc_seq_param()
1764 ITEM_SET(param, &desc->seq, log2_min_luma_coding_block_size_minus3); in h265_fill_enc_seq_param()
1765 ITEM_SET(param, &desc->seq, log2_diff_max_min_luma_coding_block_size); in h265_fill_enc_seq_param()
1766 ITEM_SET(param, &desc->seq, log2_min_transform_block_size_minus2); in h265_fill_enc_seq_param()
1767 ITEM_SET(param, &desc->seq, log2_diff_max_min_transform_block_size); in h265_fill_enc_seq_param()
1768 ITEM_SET(param, &desc->seq, max_transform_hierarchy_depth_inter); in h265_fill_enc_seq_param()
1769 ITEM_SET(param, &desc->seq, max_transform_hierarchy_depth_intra); in h265_fill_enc_seq_param()
1774 ITEM_SET(param, &desc->seq, vui_parameters_present_flag); in h265_fill_enc_seq_param()
1777 if (desc->seq.vui_parameters_present_flag) { in h265_fill_enc_seq_param()
1778 ITEM_SET(&param->vui_fields.bits, &desc->seq.vui_flags, in h265_fill_enc_seq_param()
1783 if (desc->seq.vui_parameters_present_flag) { in h265_fill_enc_seq_param()
1784 param->vui_fields.bits.vui_timing_info_present_flag = in h265_fill_enc_seq_param()
1785 desc->seq.vui_flags.timing_info_present_flag; in h265_fill_enc_seq_param()
1794 if (desc->seq.vui_parameters_present_flag) { in h265_fill_enc_seq_param()
1795 ITEM_SET(param, &desc->seq, aspect_ratio_idc); in h265_fill_enc_seq_param()
1796 ITEM_SET(param, &desc->seq, sar_width); in h265_fill_enc_seq_param()
1797 ITEM_SET(param, &desc->seq, sar_height); in h265_fill_enc_seq_param()
1799 param->vui_num_units_in_tick = desc->seq.num_units_in_tick; in h265_fill_enc_seq_param()
1800 param->vui_time_scale = desc->seq.time_scale; in h265_fill_enc_seq_param()
1815 const struct virgl_h265_enc_picture_desc *desc, in h265_fill_enc_picture_param() argument
1822 param->decoded_curr_pic.picture_id = get_enc_ref_pic(codec, desc->frame_num); in h265_fill_enc_picture_param()
1823 param->decoded_curr_pic.pic_order_cnt = desc->pic_order_cnt; in h265_fill_enc_picture_param()
1826 h265_init_picture(&param->reference_frames[i]); in h265_fill_enc_picture_param()
1829 param->coded_buf = codec->va_coded_buf; in h265_fill_enc_picture_param()
1832 param->pic_init_qp = desc->rc.quant_i_frames; in h265_fill_enc_picture_param()
1840 ITEM_SET(param, &desc->pic, log2_parallel_merge_level_minus2); in h265_fill_enc_picture_param()
1842 param->num_ref_idx_l0_default_active_minus1 = desc->num_ref_idx_l0_active_minus1; in h265_fill_enc_picture_param()
1843 param->num_ref_idx_l1_default_active_minus1 = desc->num_ref_idx_l1_active_minus1; in h265_fill_enc_picture_param()
1845 ITEM_SET(param, &desc->pic, nal_unit_type); in h265_fill_enc_picture_param()
1847 param->pic_fields.bits.idr_pic_flag = in h265_fill_enc_picture_param()
1848 (desc->picture_type == PIPE_H2645_ENC_PICTURE_TYPE_IDR); in h265_fill_enc_picture_param()
1849 switch (desc->picture_type) { in h265_fill_enc_picture_param()
1852 param->pic_fields.bits.coding_type = 1; in h265_fill_enc_picture_param()
1855 param->pic_fields.bits.coding_type = 2; in h265_fill_enc_picture_param()
1858 param->pic_fields.bits.coding_type = 3; in h265_fill_enc_picture_param()
1864 param->pic_fields.bits.reference_pic_flag = !desc->not_referenced; in h265_fill_enc_picture_param()
1867 ITEM_SET(&param->pic_fields.bits, &desc->pic, constrained_intra_pred_flag); in h265_fill_enc_picture_param()
1868 ITEM_SET(&param->pic_fields.bits, &desc->pic, transform_skip_enabled_flag); in h265_fill_enc_picture_param()
1876 ITEM_SET(&param->pic_fields.bits, &desc->pic, in h265_fill_enc_picture_param()
1894 const struct virgl_h265_enc_picture_desc *desc, in h265_fill_enc_slice_param() argument
1903 if (desc->num_slice_descriptors && in h265_fill_enc_slice_param()
1904 desc->num_slice_descriptors <= ARRAY_SIZE(desc->slices_descriptors)) { in h265_fill_enc_slice_param()
1905 sd = &desc->slices_descriptors[desc->num_slice_descriptors - 1]; in h265_fill_enc_slice_param()
1910 switch (desc->picture_type) { in h265_fill_enc_slice_param()
1912 param->slice_type = 0; in h265_fill_enc_slice_param()
1915 param->slice_type = 1; in h265_fill_enc_slice_param()
1919 param->slice_type = 2; in h265_fill_enc_slice_param()
1932 h265_init_picture(&param->ref_pic_list0[i]); in h265_fill_enc_slice_param()
1933 h265_init_picture(&param->ref_pic_list1[i]); in h265_fill_enc_slice_param()
1935 param->ref_pic_list0[i].picture_id = in h265_fill_enc_slice_param()
1936 get_enc_ref_pic(codec, desc->ref_idx_l0_list[i]); in h265_fill_enc_slice_param()
1937 param->ref_pic_list1[i].picture_id = in h265_fill_enc_slice_param()
1938 get_enc_ref_pic(codec, desc->ref_idx_l1_list[i]); in h265_fill_enc_slice_param()
1940 if (param->ref_pic_list0[i].picture_id != VA_INVALID_ID) in h265_fill_enc_slice_param()
1941 param->ref_pic_list0[i].flags = VA_PICTURE_HEVC_RPS_ST_CURR_BEFORE; in h265_fill_enc_slice_param()
1943 if (param->ref_pic_list1[i].picture_id != VA_INVALID_ID) in h265_fill_enc_slice_param()
1944 param->ref_pic_list1[i].flags = VA_PICTURE_HEVC_RPS_ST_CURR_BEFORE; in h265_fill_enc_slice_param()
1957 ITEM_SET(param, &desc->slice, max_num_merge_cand); in h265_fill_enc_slice_param()
1959 ITEM_SET(param, &desc->slice, slice_cb_qp_offset); in h265_fill_enc_slice_param()
1960 ITEM_SET(param, &desc->slice, slice_cr_qp_offset); in h265_fill_enc_slice_param()
1961 ITEM_SET(param, &desc->slice, slice_beta_offset_div2); in h265_fill_enc_slice_param()
1962 ITEM_SET(param, &desc->slice, slice_tc_offset_div2); in h265_fill_enc_slice_param()
1975 param->slice_fields.bits.num_ref_idx_active_override_flag = 0; in h265_fill_enc_slice_param()
1977 ITEM_SET(&param->slice_fields.bits, &desc->slice, cabac_init_flag); in h265_fill_enc_slice_param()
1978 ITEM_SET(&param->slice_fields.bits, &desc->slice, in h265_fill_enc_slice_param()
1980 ITEM_SET(&param->slice_fields.bits, in h265_fill_enc_slice_param()
1981 &desc->slice, slice_loop_filter_across_slices_enabled_flag); in h265_fill_enc_slice_param()
1995 const struct virgl_h265_enc_picture_desc *desc, in h265_fill_enc_misc_param_rate_ctrl() argument
2001 param->bits_per_second = desc->rc.peak_bitrate; in h265_fill_enc_misc_param_rate_ctrl()
2002 if (desc->rc.rate_ctrl_method != in h265_fill_enc_misc_param_rate_ctrl()
2004 param->target_percentage = desc->rc.target_bitrate * in h265_fill_enc_misc_param_rate_ctrl()
2005 param->bits_per_second / 100.0; in h265_fill_enc_misc_param_rate_ctrl()
2009 param->min_qp = desc->rc.min_qp; in h265_fill_enc_misc_param_rate_ctrl()
2014 param->rc_flags.bits.disable_frame_skip = !desc->rc.skip_frame_enable; in h265_fill_enc_misc_param_rate_ctrl()
2015 param->rc_flags.bits.disable_bit_stuffing = !desc->rc.fill_data_enable; in h265_fill_enc_misc_param_rate_ctrl()
2024 param->max_qp = desc->rc.max_qp; in h265_fill_enc_misc_param_rate_ctrl()
2036 const struct virgl_h265_enc_picture_desc *desc, in h265_fill_enc_misc_param_frame_rate() argument
2042 param->framerate = desc->rc.frame_rate_num | (desc->rc.frame_rate_den << 16); in h265_fill_enc_misc_param_frame_rate()
2048 const struct virgl_h265_picture_desc *desc, in h265_decode_bitstream() argument
2063 return -1; in h265_decode_bitstream()
2066 h265_fill_picture_param(codec, target, desc, &pic_param); in h265_decode_bitstream()
2067 vaCreateBuffer(va_dpy, codec->va_ctx, VAPictureParameterBufferType, in h265_decode_bitstream()
2070 h265_fill_slice_param(desc, &slice_param); in h265_decode_bitstream()
2071 vaCreateBuffer(va_dpy, codec->va_ctx, VASliceParameterBufferType, in h265_decode_bitstream()
2075 vaCreateBuffer(va_dpy, codec->va_ctx, VASliceDataBufferType, in h265_decode_bitstream()
2079 va_stat = vaRenderPicture(va_dpy, codec->va_ctx, &pic_param_buf, 1); in h265_decode_bitstream()
2082 err = -1; in h265_decode_bitstream()
2086 va_stat = vaRenderPicture(va_dpy, codec->va_ctx, &slice_param_buf, 1); in h265_decode_bitstream()
2089 err = -1; in h265_decode_bitstream()
2094 va_stat = vaRenderPicture(va_dpy, codec->va_ctx, &slice_data_buf[i], 1); in h265_decode_bitstream()
2098 err = -1; in h265_decode_bitstream()
2115 const struct virgl_h265_enc_picture_desc *desc) in h265_encode_render_sequence() argument
2124 h265_fill_enc_seq_param(codec, source, desc, &seq_param); in h265_encode_render_sequence()
2125 vaCreateBuffer(va_dpy, codec->va_ctx, VAEncSequenceParameterBufferType, in h265_encode_render_sequence()
2128 vaCreateBuffer(va_dpy, codec->va_ctx, VAEncMiscParameterBufferType, in h265_encode_render_sequence()
2132 misc_param->type = VAEncMiscParameterTypeRateControl; in h265_encode_render_sequence()
2133 h265_fill_enc_misc_param_rate_ctrl(codec, source, desc, in h265_encode_render_sequence()
2134 (VAEncMiscParameterRateControl *)misc_param->data); in h265_encode_render_sequence()
2137 vaCreateBuffer(va_dpy, codec->va_ctx, VAEncMiscParameterBufferType, in h265_encode_render_sequence()
2141 misc_param->type = VAEncMiscParameterTypeFrameRate; in h265_encode_render_sequence()
2142 h265_fill_enc_misc_param_frame_rate(codec, source, desc, in h265_encode_render_sequence()
2143 (VAEncMiscParameterFrameRate *)misc_param->data); in h265_encode_render_sequence()
2146 va_stat = vaRenderPicture(va_dpy, codec->va_ctx, &seq_param_buf, 1); in h265_encode_render_sequence()
2149 err = -1; in h265_encode_render_sequence()
2153 va_stat = vaRenderPicture(va_dpy, codec->va_ctx, &rc_param_buf, 1); in h265_encode_render_sequence()
2156 err = -1; in h265_encode_render_sequence()
2160 va_stat = vaRenderPicture(va_dpy, codec->va_ctx, &fr_param_buf, 1); in h265_encode_render_sequence()
2163 err = -1; in h265_encode_render_sequence()
2178 const struct virgl_h265_enc_picture_desc *desc) in h265_encode_render_picture() argument
2185 h265_fill_enc_picture_param(codec, source, desc, &pic_param); in h265_encode_render_picture()
2186 vaCreateBuffer(va_dpy, codec->va_ctx, VAEncPictureParameterBufferType, in h265_encode_render_picture()
2189 va_stat = vaRenderPicture(va_dpy, codec->va_ctx, &pic_param_buf, 1); in h265_encode_render_picture()
2194 return -1; in h265_encode_render_picture()
2203 const struct virgl_h265_enc_picture_desc *desc) in h265_encode_render_slice() argument
2210 h265_fill_enc_slice_param(codec, source, desc, &slice_param); in h265_encode_render_slice()
2211 vaCreateBuffer(va_dpy, codec->va_ctx, VAEncSliceParameterBufferType, in h265_encode_render_slice()
2214 va_stat = vaRenderPicture(va_dpy, codec->va_ctx, &slice_param_buf, 1); in h265_encode_render_slice()
2219 return -1; in h265_encode_render_slice()
2228 const struct virgl_h265_enc_picture_desc *desc) in h265_encode_bitstream() argument
2230 if (desc->picture_type == PIPE_H2645_ENC_PICTURE_TYPE_IDR) { in h265_encode_bitstream()
2231 h265_encode_render_sequence(codec, source, desc); in h265_encode_bitstream()
2234 h265_encode_render_picture(codec, source, desc); in h265_encode_bitstream()
2235 h265_encode_render_slice(codec, source, desc); in h265_encode_bitstream()
2242 const union virgl_picture_desc *desc, in virgl_video_decode_bitstream() argument
2248 if (!va_dpy || !codec || !target || !desc in virgl_video_decode_bitstream()
2250 return -1; in virgl_video_decode_bitstream()
2252 if (desc->base.profile != codec->profile) { in virgl_video_decode_bitstream()
2254 desc->base.profile, codec->profile); in virgl_video_decode_bitstream()
2255 return -1; in virgl_video_decode_bitstream()
2258 switch (codec->profile) { in virgl_video_decode_bitstream()
2267 return h264_decode_bitstream(codec, target, &desc->h264, in virgl_video_decode_bitstream()
2274 return h265_decode_bitstream(codec, target, &desc->h265, in virgl_video_decode_bitstream()
2280 return -1; in virgl_video_decode_bitstream()
2285 const union virgl_picture_desc *desc) in virgl_video_encode_bitstream() argument
2287 if (!va_dpy || !codec || !source || !desc) in virgl_video_encode_bitstream()
2288 return -1; in virgl_video_encode_bitstream()
2290 if (desc->base.profile != codec->profile) { in virgl_video_encode_bitstream()
2292 desc->base.profile, codec->profile); in virgl_video_encode_bitstream()
2293 return -1; in virgl_video_encode_bitstream()
2296 switch (codec->profile) { in virgl_video_encode_bitstream()
2305 return h264_encode_bitstream(codec, source, &desc->h264_enc); in virgl_video_encode_bitstream()
2311 return h265_encode_bitstream(codec, source, &desc->h265_enc); in virgl_video_encode_bitstream()
2316 return -1; in virgl_video_encode_bitstream()
2325 return -1; in virgl_video_end_frame()
2327 va_stat = vaEndPicture(va_dpy, codec->va_ctx); in virgl_video_end_frame()
2330 return -1; in virgl_video_end_frame()
2333 va_stat = vaSyncSurface(va_dpy, target->va_sfc); in virgl_video_end_frame()
2336 return -1; in virgl_video_end_frame()
2339 if (codec->entrypoint != PIPE_VIDEO_ENTRYPOINT_ENCODE) { in virgl_video_end_frame()