- struct r600_texture *luma = (struct r600_texture *)
- ((struct vl_video_buffer *)target)->resources[0];
- struct r600_texture *chroma = (struct r600_texture *)
- ((struct vl_video_buffer *)target)->resources[1];
- rvcn_dec_message_header_t *header;
- rvcn_dec_message_index_t *index;
- rvcn_dec_message_decode_t *decode;
- unsigned sizes = 0, offset_decode, offset_codec;
- void *codec;
-
- header = dec->msg;
- sizes += sizeof(rvcn_dec_message_header_t);
- index = (void*)header + sizeof(rvcn_dec_message_header_t);
- sizes += sizeof(rvcn_dec_message_index_t);
- offset_decode = sizes;
- decode = (void*)index + sizeof(rvcn_dec_message_index_t);
- sizes += sizeof(rvcn_dec_message_decode_t);
- offset_codec = sizes;
- codec = (void*)decode + sizeof(rvcn_dec_message_decode_t);
-
- memset(dec->msg, 0, sizes);
- header->header_size = sizeof(rvcn_dec_message_header_t);
- header->total_size = sizes;
- header->num_buffers = 2;
- header->msg_type = RDECODE_MSG_DECODE;
- header->stream_handle = dec->stream_handle;
- header->status_report_feedback_number = dec->frame_number;
-
- header->index[0].message_id = RDECODE_MESSAGE_DECODE;
- header->index[0].offset = offset_decode;
- header->index[0].size = sizeof(rvcn_dec_message_decode_t);
- header->index[0].filled = 0;
-
- index->offset = offset_codec;
- index->size = sizeof(rvcn_dec_message_avc_t);
- index->filled = 0;
-
- decode->stream_type = dec->stream_type;
- decode->decode_flags = 0x1;
- decode->width_in_samples = dec->base.width;
- decode->height_in_samples = dec->base.height;
-
- decode->bsd_size = align(dec->bs_size, 128);
- decode->dpb_size = dec->dpb.res->buf->size;
- decode->dt_size =
- ((struct r600_resource *)((struct vl_video_buffer *)target)->resources[0])->buf->size +
- ((struct r600_resource *)((struct vl_video_buffer *)target)->resources[1])->buf->size;
-
- decode->sct_size = 0;
- decode->sc_coeff_size = 0;
-
- decode->sw_ctxt_size = RDECODE_SESSION_CONTEXT_SIZE;
- decode->db_pitch = align(dec->base.width, 32);
- decode->db_surf_tile_config = 0;
-
- decode->dt_pitch = luma->surface.u.gfx9.surf_pitch * luma->surface.blk_w;
- decode->dt_uv_pitch = decode->dt_pitch / 2;
-
- decode->dt_tiling_mode = 0;
- decode->dt_swizzle_mode = RDECODE_SW_MODE_LINEAR;
- decode->dt_array_mode = RDECODE_ARRAY_MODE_LINEAR;
- decode->dt_field_mode = ((struct vl_video_buffer *)target)->base.interlaced;
- decode->dt_surf_tile_config = 0;
- decode->dt_uv_surf_tile_config = 0;
-
- decode->dt_luma_top_offset = luma->surface.u.gfx9.surf_offset;
- decode->dt_chroma_top_offset = chroma->surface.u.gfx9.surf_offset;
- if (decode->dt_field_mode) {
- decode->dt_luma_bottom_offset = luma->surface.u.gfx9.surf_offset +
- luma->surface.u.gfx9.surf_slice_size;
- decode->dt_chroma_bottom_offset = chroma->surface.u.gfx9.surf_offset +
- chroma->surface.u.gfx9.surf_slice_size;
- } else {
- decode->dt_luma_bottom_offset = decode->dt_luma_top_offset;
- decode->dt_chroma_bottom_offset = decode->dt_chroma_top_offset;
- }
-
- switch (u_reduce_video_profile(picture->profile)) {
- case PIPE_VIDEO_FORMAT_MPEG4_AVC: {
- rvcn_dec_message_avc_t avc =
- get_h264_msg(dec, (struct pipe_h264_picture_desc*)picture);
- memcpy(codec, (void*)&avc, sizeof(rvcn_dec_message_avc_t));
- index->message_id = RDECODE_MESSAGE_AVC;
- break;
- }
- case PIPE_VIDEO_FORMAT_HEVC: {
- rvcn_dec_message_hevc_t hevc =
- get_h265_msg(dec, target, (struct pipe_h265_picture_desc*)picture);
-
- memcpy(codec, (void*)&hevc, sizeof(rvcn_dec_message_hevc_t));
- index->message_id = RDECODE_MESSAGE_HEVC;
- if (dec->ctx.res == NULL) {
- unsigned ctx_size;
- if (dec->base.profile == PIPE_VIDEO_PROFILE_HEVC_MAIN_10)
- ctx_size = calc_ctx_size_h265_main10(dec,
- (struct pipe_h265_picture_desc*)picture);
- else
- ctx_size = calc_ctx_size_h265_main(dec);
- if (!si_vid_create_buffer(dec->screen, &dec->ctx, ctx_size, PIPE_USAGE_DEFAULT))
- RVID_ERR("Can't allocated context buffer.\n");
- si_vid_clear_buffer(dec->base.context, &dec->ctx);
- }
- break;
- }
- case PIPE_VIDEO_FORMAT_VC1: {
- rvcn_dec_message_vc1_t vc1 = get_vc1_msg((struct pipe_vc1_picture_desc*)picture);
-
- memcpy(codec, (void*)&vc1, sizeof(rvcn_dec_message_vc1_t));
- if ((picture->profile == PIPE_VIDEO_PROFILE_VC1_SIMPLE) ||
- (picture->profile == PIPE_VIDEO_PROFILE_VC1_MAIN)) {
- decode->width_in_samples = align(decode->width_in_samples, 16) / 16;
- decode->height_in_samples = align(decode->height_in_samples, 16) / 16;
- }
- index->message_id = RDECODE_MESSAGE_VC1;
- break;
-
- }
- case PIPE_VIDEO_FORMAT_MPEG12: {
- rvcn_dec_message_mpeg2_vld_t mpeg2 =
- get_mpeg2_msg(dec, (struct pipe_mpeg12_picture_desc*)picture);
-
- memcpy(codec, (void*)&mpeg2, sizeof(rvcn_dec_message_mpeg2_vld_t));
- index->message_id = RDECODE_MESSAGE_MPEG2_VLD;
- break;
- }
- case PIPE_VIDEO_FORMAT_MPEG4: {
- rvcn_dec_message_mpeg4_asp_vld_t mpeg4 =
- get_mpeg4_msg(dec, (struct pipe_mpeg4_picture_desc*)picture);
-
- memcpy(codec, (void*)&mpeg4, sizeof(rvcn_dec_message_mpeg4_asp_vld_t));
- index->message_id = RDECODE_MESSAGE_MPEG4_ASP_VLD;
- break;
- }
- case PIPE_VIDEO_FORMAT_VP9: {
- rvcn_dec_message_vp9_t vp9 =
- get_vp9_msg(dec, target, (struct pipe_vp9_picture_desc*)picture);
-
- memcpy(codec, (void*)&vp9, sizeof(rvcn_dec_message_vp9_t));
- index->message_id = RDECODE_MESSAGE_VP9;
-
- if (dec->ctx.res == NULL) {
- unsigned ctx_size;
- uint8_t *ptr;
-
- /* default probability + probability data */
- ctx_size = 2304 * 5;
-
- /* SRE collocated context data */
- ctx_size += 32 * 2 * 64 * 64;
-
- /* SMP collocated context data */
- ctx_size += 9 * 64 * 2 * 64 * 64;
-
- /* SDB left tile pixel */
- ctx_size += 8 * 2 * 4096;
-
- if (dec->base.profile == PIPE_VIDEO_PROFILE_VP9_PROFILE2)
- ctx_size += 8 * 2 * 4096;
-
- if (!si_vid_create_buffer(dec->screen, &dec->ctx, ctx_size, PIPE_USAGE_DEFAULT))
- RVID_ERR("Can't allocated context buffer.\n");
- si_vid_clear_buffer(dec->base.context, &dec->ctx);
-
- /* ctx needs probs table */
- ptr = dec->ws->buffer_map(dec->ctx.res->buf, dec->cs, PIPE_TRANSFER_WRITE);
- fill_probs_table(ptr);
- dec->ws->buffer_unmap(dec->ctx.res->buf);
- }
- break;
- }
- default:
- assert(0);
- return NULL;
- }
-
- if (dec->ctx.res)
- decode->hw_ctxt_size = dec->ctx.res->buf->size;
-
- return luma->resource.buf;
+ struct si_texture *luma = (struct si_texture *)((struct vl_video_buffer *)target)->resources[0];
+ struct si_texture *chroma =
+ (struct si_texture *)((struct vl_video_buffer *)target)->resources[1];
+ rvcn_dec_message_header_t *header;
+ rvcn_dec_message_index_t *index;
+ rvcn_dec_message_decode_t *decode;
+ unsigned sizes = 0, offset_decode, offset_codec;
+ void *codec;
+
+ header = dec->msg;
+ sizes += sizeof(rvcn_dec_message_header_t);
+ index = (void *)header + sizeof(rvcn_dec_message_header_t);
+ sizes += sizeof(rvcn_dec_message_index_t);
+ offset_decode = sizes;
+ decode = (void *)index + sizeof(rvcn_dec_message_index_t);
+ sizes += sizeof(rvcn_dec_message_decode_t);
+ offset_codec = sizes;
+ codec = (void *)decode + sizeof(rvcn_dec_message_decode_t);
+
+ memset(dec->msg, 0, sizes);
+ header->header_size = sizeof(rvcn_dec_message_header_t);
+ header->total_size = sizes;
+ header->num_buffers = 2;
+ header->msg_type = RDECODE_MSG_DECODE;
+ header->stream_handle = dec->stream_handle;
+ header->status_report_feedback_number = dec->frame_number;
+
+ header->index[0].message_id = RDECODE_MESSAGE_DECODE;
+ header->index[0].offset = offset_decode;
+ header->index[0].size = sizeof(rvcn_dec_message_decode_t);
+ header->index[0].filled = 0;
+
+ index->offset = offset_codec;
+ index->size = sizeof(rvcn_dec_message_avc_t);
+ index->filled = 0;
+
+ decode->stream_type = dec->stream_type;
+ decode->decode_flags = 0;
+ decode->width_in_samples = dec->base.width;
+ decode->height_in_samples = dec->base.height;
+
+ decode->bsd_size = align(dec->bs_size, 128);
+ decode->dpb_size = dec->dpb.res->buf->size;
+ decode->dt_size = si_resource(((struct vl_video_buffer *)target)->resources[0])->buf->size +
+ si_resource(((struct vl_video_buffer *)target)->resources[1])->buf->size;
+
+ decode->sct_size = 0;
+ decode->sc_coeff_size = 0;
+
+ decode->sw_ctxt_size = RDECODE_SESSION_CONTEXT_SIZE;
+ decode->db_pitch = (((struct si_screen *)dec->screen)->info.family >= CHIP_RENOIR &&
+ dec->base.width > 32 && dec->stream_type == RDECODE_CODEC_VP9)
+ ? align(dec->base.width, 64)
+ : align(dec->base.width, 32);
+ if (((struct si_screen*)dec->screen)->info.family >= CHIP_SIENNA_CICHLID &&
+ dec->stream_type == RDECODE_CODEC_VP9)
+ decode->db_aligned_height = align(dec->base.height, 64);
+
+ decode->db_surf_tile_config = 0;
+
+ decode->dt_pitch = luma->surface.u.gfx9.surf_pitch * luma->surface.blk_w;
+ decode->dt_uv_pitch = decode->dt_pitch / 2;
+
+ decode->dt_tiling_mode = 0;
+ decode->dt_swizzle_mode = RDECODE_SW_MODE_LINEAR;
+ decode->dt_array_mode = RDECODE_ARRAY_MODE_LINEAR;
+ decode->dt_field_mode = ((struct vl_video_buffer *)target)->base.interlaced;
+ decode->dt_surf_tile_config = 0;
+ decode->dt_uv_surf_tile_config = 0;
+
+ decode->dt_luma_top_offset = luma->surface.u.gfx9.surf_offset;
+ decode->dt_chroma_top_offset = chroma->surface.u.gfx9.surf_offset;
+ if (decode->dt_field_mode) {
+ decode->dt_luma_bottom_offset =
+ luma->surface.u.gfx9.surf_offset + luma->surface.u.gfx9.surf_slice_size;
+ decode->dt_chroma_bottom_offset =
+ chroma->surface.u.gfx9.surf_offset + chroma->surface.u.gfx9.surf_slice_size;
+ } else {
+ decode->dt_luma_bottom_offset = decode->dt_luma_top_offset;
+ decode->dt_chroma_bottom_offset = decode->dt_chroma_top_offset;
+ }
+
+ switch (u_reduce_video_profile(picture->profile)) {
+ case PIPE_VIDEO_FORMAT_MPEG4_AVC: {
+ rvcn_dec_message_avc_t avc = get_h264_msg(dec, (struct pipe_h264_picture_desc *)picture);
+ memcpy(codec, (void *)&avc, sizeof(rvcn_dec_message_avc_t));
+ index->message_id = RDECODE_MESSAGE_AVC;
+ break;
+ }
+ case PIPE_VIDEO_FORMAT_HEVC: {
+ rvcn_dec_message_hevc_t hevc =
+ get_h265_msg(dec, target, (struct pipe_h265_picture_desc *)picture);
+
+ memcpy(codec, (void *)&hevc, sizeof(rvcn_dec_message_hevc_t));
+ index->message_id = RDECODE_MESSAGE_HEVC;
+ if (dec->ctx.res == NULL) {
+ unsigned ctx_size;
+ if (dec->base.profile == PIPE_VIDEO_PROFILE_HEVC_MAIN_10)
+ ctx_size = calc_ctx_size_h265_main10(dec, (struct pipe_h265_picture_desc *)picture);
+ else
+ ctx_size = calc_ctx_size_h265_main(dec);
+ if (!si_vid_create_buffer(dec->screen, &dec->ctx, ctx_size, PIPE_USAGE_DEFAULT))
+ RVID_ERR("Can't allocated context buffer.\n");
+ si_vid_clear_buffer(dec->base.context, &dec->ctx);
+ }
+ break;
+ }
+ case PIPE_VIDEO_FORMAT_VC1: {
+ rvcn_dec_message_vc1_t vc1 = get_vc1_msg((struct pipe_vc1_picture_desc *)picture);
+
+ memcpy(codec, (void *)&vc1, sizeof(rvcn_dec_message_vc1_t));
+ if ((picture->profile == PIPE_VIDEO_PROFILE_VC1_SIMPLE) ||
+ (picture->profile == PIPE_VIDEO_PROFILE_VC1_MAIN)) {
+ decode->width_in_samples = align(decode->width_in_samples, 16) / 16;
+ decode->height_in_samples = align(decode->height_in_samples, 16) / 16;
+ }
+ index->message_id = RDECODE_MESSAGE_VC1;
+ break;
+ }
+ case PIPE_VIDEO_FORMAT_MPEG12: {
+ rvcn_dec_message_mpeg2_vld_t mpeg2 =
+ get_mpeg2_msg(dec, (struct pipe_mpeg12_picture_desc *)picture);
+
+ memcpy(codec, (void *)&mpeg2, sizeof(rvcn_dec_message_mpeg2_vld_t));
+ index->message_id = RDECODE_MESSAGE_MPEG2_VLD;
+ break;
+ }
+ case PIPE_VIDEO_FORMAT_MPEG4: {
+ rvcn_dec_message_mpeg4_asp_vld_t mpeg4 =
+ get_mpeg4_msg(dec, (struct pipe_mpeg4_picture_desc *)picture);
+
+ memcpy(codec, (void *)&mpeg4, sizeof(rvcn_dec_message_mpeg4_asp_vld_t));
+ index->message_id = RDECODE_MESSAGE_MPEG4_ASP_VLD;
+ break;
+ }
+ case PIPE_VIDEO_FORMAT_VP9: {
+ rvcn_dec_message_vp9_t vp9 =
+ get_vp9_msg(dec, target, (struct pipe_vp9_picture_desc *)picture);
+
+ memcpy(codec, (void *)&vp9, sizeof(rvcn_dec_message_vp9_t));
+ index->message_id = RDECODE_MESSAGE_VP9;
+
+ if (dec->ctx.res == NULL) {
+ unsigned ctx_size;
+ uint8_t *ptr;
+
+ /* default probability + probability data */
+ ctx_size = 2304 * 5;
+
+ if (((struct si_screen *)dec->screen)->info.family >= CHIP_RENOIR) {
+ /* SRE collocated context data */
+ ctx_size += 32 * 2 * 128 * 68;
+ /* SMP collocated context data */
+ ctx_size += 9 * 64 * 2 * 128 * 68;
+ /* SDB left tile pixel */
+ ctx_size += 8 * 2 * 2 * 8192;
+ } else {
+ ctx_size += 32 * 2 * 64 * 64;
+ ctx_size += 9 * 64 * 2 * 64 * 64;
+ ctx_size += 8 * 2 * 4096;
+ }
+
+ if (dec->base.profile == PIPE_VIDEO_PROFILE_VP9_PROFILE2)
+ ctx_size += 8 * 2 * 4096;
+
+ if (!si_vid_create_buffer(dec->screen, &dec->ctx, ctx_size, PIPE_USAGE_DEFAULT))
+ RVID_ERR("Can't allocated context buffer.\n");
+ si_vid_clear_buffer(dec->base.context, &dec->ctx);
+
+ /* ctx needs probs table */
+ ptr = dec->ws->buffer_map(dec->ctx.res->buf, dec->cs,
+ PIPE_TRANSFER_WRITE | RADEON_TRANSFER_TEMPORARY);
+ fill_probs_table(ptr);
+ dec->ws->buffer_unmap(dec->ctx.res->buf);
+ }
+ break;
+ }
+ default:
+ assert(0);
+ return NULL;
+ }
+
+ if (dec->ctx.res)
+ decode->hw_ctxt_size = dec->ctx.res->buf->size;
+
+ return luma->buffer.buf;