1 2 /* 3 * Copyright © Microsoft Corporation 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice (including the next 13 * paragraph) shall be included in all copies or substantial portions of the 14 * Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 * IN THE SOFTWARE. 23 */ 24 25 #ifndef D3D12_VIDEO_DEC_VP9_H 26 #define D3D12_VIDEO_DEC_VP9_H 27 28 #include "d3d12_video_types.h" 29 30 constexpr uint16_t DXVA_VP9_INVALID_PICTURE_INDEX = 0x7F; 31 constexpr uint16_t DXVA_VP9_INVALID_PICTURE_ENTRY = 0xFF; 32 33 #pragma pack(push, BeforeDXVApacking, 1) 34 35 /* VPx picture entry data structure */ 36 typedef struct _DXVA_PicEntry_VPx { 37 union { 38 struct { 39 uint8_t Index7Bits : 7; 40 uint8_t AssociatedFlag : 1; 41 }; 42 uint8_t bPicEntry; 43 }; 44 } DXVA_PicEntry_VPx, *LPDXVA_PicEntry_VPx; 45 46 /* VP9 segmentation structure */ 47 typedef struct _segmentation_VP9 { 48 union { 49 struct { 50 uint8_t enabled : 1; 51 uint8_t update_map : 1; 52 uint8_t temporal_update : 1; 53 uint8_t abs_delta : 1; 54 uint8_t ReservedSegmentFlags4Bits : 4; 55 }; 56 uint8_t wSegmentInfoFlags; 57 }; 58 uint8_t tree_probs[7]; 59 uint8_t pred_probs[3]; 60 int16_t feature_data[8][4]; 61 uint8_t feature_mask[8]; 62 } DXVA_segmentation_VP9; 63 64 /* VP9 picture parameters structure */ 65 typedef struct _DXVA_PicParams_VP9 { 66 DXVA_PicEntry_VPx CurrPic; 67 uint8_t profile; 68 union { 69 struct { 70 uint16_t frame_type : 1; 71 uint16_t show_frame : 1; 72 uint16_t error_resilient_mode : 1; 73 uint16_t subsampling_x : 1; 74 uint16_t subsampling_y : 1; 75 uint16_t extra_plane : 1; 76 uint16_t refresh_frame_context : 1; 77 uint16_t frame_parallel_decoding_mode : 1; 78 uint16_t intra_only : 1; 79 uint16_t frame_context_idx : 2; 80 uint16_t reset_frame_context : 2; 81 uint16_t allow_high_precision_mv : 1; 82 uint16_t ReservedFormatInfo2Bits : 2; 83 }; 84 uint16_t wFormatAndPictureInfoFlags; 85 }; 86 uint32_t width; 87 uint32_t height; 88 uint8_t BitDepthMinus8Luma; 89 uint8_t BitDepthMinus8Chroma; 90 uint8_t interp_filter; 91 uint8_t Reserved8Bits; 92 DXVA_PicEntry_VPx ref_frame_map[8]; 93 uint32_t ref_frame_coded_width[8]; 94 uint32_t ref_frame_coded_height[8]; 95 DXVA_PicEntry_VPx frame_refs[3]; 96 char ref_frame_sign_bias[4]; 97 char filter_level; 98 char sharpness_level; 99 union { 100 struct { 101 uint8_t mode_ref_delta_enabled : 1; 102 uint8_t mode_ref_delta_update : 1; 103 uint8_t use_prev_in_find_mv_refs : 1; 104 uint8_t ReservedControlInfo5Bits : 5; 105 }; 106 uint8_t wControlInfoFlags; 107 }; 108 char ref_deltas[4]; 109 char mode_deltas[2]; 110 int16_t base_qindex; 111 char y_dc_delta_q; 112 char uv_dc_delta_q; 113 char uv_ac_delta_q; 114 DXVA_segmentation_VP9 stVP9Segments; 115 uint8_t log2_tile_cols; 116 uint8_t log2_tile_rows; 117 uint16_t uncompressed_header_size_byte_aligned; 118 uint16_t first_partition_size; 119 uint16_t Reserved16Bits; 120 uint32_t Reserved32Bits; 121 uint32_t StatusReportFeedbackNumber; 122 } DXVA_PicParams_VP9, *LPDXVA_PicParams_VP9; 123 124 /* VPx slice control data structure - short form */ 125 typedef struct _DXVA_Slice_VPx_Short { 126 uint32_t BSNALunitDataLocation; 127 uint32_t SliceBytesInBuffer; 128 uint16_t wBadSliceChopping; 129 } DXVA_Slice_VPx_Short, *LPDXVA_Slice_VPx_Short; 130 131 #pragma pack(pop, BeforeDXVApacking) 132 133 void 134 d3d12_video_decoder_prepare_current_frame_references_vp9(struct d3d12_video_decoder *pD3D12Dec, 135 ID3D12Resource *pTexture2D, 136 uint32_t subresourceIndex); 137 138 void 139 d3d12_video_decoder_refresh_dpb_active_references_vp9(struct d3d12_video_decoder *pD3D12Dec); 140 141 void 142 d3d12_video_decoder_get_frame_info_vp9( 143 struct d3d12_video_decoder *pD3D12Dec, uint32_t *pWidth, uint32_t *pHeight, uint16_t *pMaxDPB); 144 145 DXVA_PicParams_VP9 146 d3d12_video_decoder_dxva_picparams_from_pipe_picparams_vp9( 147 struct d3d12_video_decoder *pD3D12Dec, 148 pipe_video_profile profile, 149 pipe_vp9_picture_desc *pPipeDesc); 150 151 void 152 d3d12_video_decoder_log_pic_params_vp9(DXVA_PicParams_VP9 *pPicParams); 153 154 void 155 d3d12_video_decoder_prepare_dxva_slices_control_vp9(struct d3d12_video_decoder *pD3D12Dec, 156 std::vector<uint8_t> &vecOutSliceControlBuffers, 157 struct pipe_vp9_picture_desc *picture_vp9); 158 159 #endif 160