1 /* 2 * Copyright 2021 Rockchip Electronics Co. LTD 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef _AV1D_SYNTAX_H_ 18 #define _AV1D_SYNTAX_H_ 19 20 typedef unsigned long DWORD; 21 typedef unsigned char BYTE; 22 typedef unsigned short WORD; 23 typedef unsigned long ULONG; 24 typedef unsigned short USHORT; 25 typedef unsigned char UCHAR; 26 typedef unsigned int UINT; 27 typedef unsigned int UINT32; 28 29 typedef signed int BOOL; 30 typedef signed int INT; 31 typedef signed char CHAR; 32 typedef signed short SHORT; 33 typedef signed long LONG; 34 typedef void *PVOID; 35 36 typedef struct _DXVA_PicEntry_AV1 { 37 union { 38 struct { 39 UCHAR Index7Bits : 7; 40 UCHAR AssociatedFlag : 1; 41 }; 42 UCHAR bPicEntry; 43 }; 44 } DXVA_PicEntry_AV1, *LPDXVA_PicEntry_AV1; 45 46 47 typedef struct _DXVA_PicParams_AV1 { 48 DXVA_PicEntry_AV1 CurrPic; 49 USHORT width ; 50 USHORT height ; 51 USHORT max_width ; 52 USHORT max_height ; 53 USHORT CurrPicTextureIndex ; 54 USHORT superres_denom ; 55 USHORT bitdepth ; 56 USHORT seq_profile ; 57 USHORT frame_header_size ; 58 union { 59 struct { 60 UINT32 current_operating_point : 12; 61 UINT32 use_128x128_superblock : 1; 62 UINT32 intra_edge_filter : 1; 63 UINT32 interintra_compound : 1; 64 UINT32 masked_compound : 1; 65 UINT32 warped_motion : 1; 66 UINT32 dual_filter : 1; 67 UINT32 jnt_comp : 1; 68 UINT32 screen_content_tools : 1; 69 UINT32 integer_mv : 2; 70 UINT32 cdef_en : 1; 71 UINT32 restoration : 1; 72 UINT32 film_grain_en : 1; 73 UINT32 intrabc : 1; 74 UINT32 high_precision_mv : 1; 75 UINT32 switchable_motion_mode : 1; 76 UINT32 filter_intra : 1; 77 UINT32 disable_frame_end_update_cdf : 1; 78 UINT32 disable_cdf_update : 1; 79 UINT32 reference_mode : 1; 80 UINT32 skip_mode : 1; 81 UINT32 reduced_tx_set : 1; 82 UINT32 superres : 1; 83 UINT32 tx_mode : 3; 84 UINT32 use_ref_frame_mvs : 1; 85 UINT32 enable_ref_frame_mvs : 1; 86 UINT32 reference_frame_update : 1; 87 UINT32 error_resilient_mode : 1; 88 } coding; 89 }; 90 91 struct { 92 USHORT cols; 93 USHORT rows; 94 USHORT context_update_id; 95 USHORT widths[64]; 96 USHORT heights[64]; 97 UINT32 tile_offset_start[128]; 98 UINT32 tile_offset_end[128]; 99 UCHAR tile_sz_mag; 100 } tiles; 101 102 struct { 103 UCHAR frame_type ; 104 UCHAR show_frame ; 105 UCHAR showable_frame; 106 UCHAR subsampling_x ; 107 UCHAR subsampling_y ; 108 UCHAR mono_chrome ; 109 } format; 110 111 UCHAR primary_ref_frame; 112 UCHAR enable_order_hint; 113 UCHAR order_hint; 114 UCHAR order_hint_bits; 115 116 struct { 117 UCHAR filter_level[2] ; 118 UCHAR filter_level_u ; 119 UCHAR filter_level_v ; 120 UCHAR sharpness_level ; 121 UCHAR mode_ref_delta_enabled ; 122 UCHAR mode_ref_delta_update ; 123 UCHAR delta_lf_multi ; 124 UCHAR delta_lf_present ; 125 UCHAR delta_lf_res ; 126 CHAR ref_deltas[8] ; 127 CHAR mode_deltas[2] ; 128 UCHAR frame_restoration_type[3] ; 129 UCHAR log2_restoration_unit_size[3]; 130 } loop_filter; 131 132 struct { 133 UCHAR delta_q_present; 134 UCHAR delta_q_res ; 135 UCHAR base_qindex ; 136 CHAR y_dc_delta_q ; 137 CHAR u_dc_delta_q ; 138 CHAR v_dc_delta_q ; 139 CHAR u_ac_delta_q ; 140 CHAR v_ac_delta_q ; 141 CHAR using_qmatrix ; 142 UCHAR qm_y ; 143 UCHAR qm_u ; 144 UCHAR qm_v ; 145 } quantization; 146 147 struct { 148 UCHAR damping; 149 UCHAR bits; 150 151 struct { 152 UCHAR primary; 153 UCHAR secondary; 154 } y_strengths[8]; 155 struct { 156 UCHAR primary; 157 UCHAR secondary; 158 } uv_strengths[8]; 159 } cdef; 160 161 struct { 162 UCHAR enabled ; 163 UCHAR update_map ; 164 UCHAR update_data ; 165 UCHAR temporal_update ; 166 UCHAR feature_mask[8] ; 167 INT feature_data[8][8]; 168 UCHAR last_active ; 169 UCHAR preskip ; 170 } segmentation; 171 172 struct { 173 UCHAR apply_grain ; 174 UCHAR scaling_shift_minus8 ; 175 UCHAR chroma_scaling_from_luma ; 176 UCHAR ar_coeff_lag ; 177 UCHAR ar_coeff_shift_minus6 ; 178 UCHAR grain_scale_shift ; 179 UCHAR overlap_flag ; 180 UCHAR clip_to_restricted_range ; 181 UCHAR matrix_coefficients ; 182 UCHAR matrix_coeff_is_identity ; 183 UCHAR num_y_points ; 184 UCHAR num_cb_points ; 185 UCHAR num_cr_points ; 186 UCHAR scaling_points_y[14][2] ; 187 UCHAR scaling_points_cb[10][2] ; 188 UCHAR scaling_points_cr[10][2] ; 189 UCHAR ar_coeffs_y[24] ; 190 UCHAR ar_coeffs_cb[25] ; 191 UCHAR ar_coeffs_cr[25] ; 192 UCHAR cb_mult ; 193 UCHAR cb_luma_mult ; 194 UCHAR cr_mult ; 195 UCHAR cr_luma_mult ; 196 197 USHORT grain_seed ; 198 USHORT update_grain ; 199 USHORT cb_offset ; 200 USHORT cr_offset ; 201 } film_grain; 202 203 UINT32 ref_frame_valued; 204 UINT32 ref_frame_idx[7]; 205 206 UINT32 ref_order_hint[8]; 207 struct { 208 UINT32 width; 209 UINT32 height; 210 UINT32 order_hint; 211 UINT32 lst_frame_offset; 212 UINT32 lst2_frame_offset; 213 UINT32 lst3_frame_offset; 214 UINT32 gld_frame_offset; 215 UINT32 bwd_frame_offset; 216 UINT32 alt2_frame_offset; 217 UINT32 alt_frame_offset; 218 UINT32 is_intra_frame; 219 UINT32 intra_only; 220 CHAR Index; 221 UCHAR wminvalid; 222 UCHAR wmtype; 223 RK_S32 wmmat[6]; 224 RK_S32 wmmat_val[6]; 225 USHORT alpha, beta, gamma, delta; 226 } frame_refs[8]; 227 228 struct { 229 RK_S32 valid; // RefValid 230 RK_S32 frame_id; // RefFrameId 231 RK_S32 upscaled_width; // RefUpscaledWidth 232 RK_S32 frame_width; // RefFrameWidth 233 RK_S32 frame_height; // RefFrameHeight 234 RK_S32 render_width; // RefRenderWidth 235 RK_S32 render_height; // RefRenderHeight 236 RK_S32 frame_type; // RefFrameType 237 RK_S32 subsampling_x; // RefSubsamplingX 238 RK_S32 subsampling_y; // RefSubsamplingY 239 RK_S32 bit_depth; // RefBitDepth 240 RK_S32 order_hint; // RefOrderHint 241 } frame_ref_state[8]; 242 243 RK_U8 ref_frame_sign_bias[8]; 244 245 UCHAR coded_lossless; 246 RK_S32 all_lossless; 247 UCHAR interp_filter; 248 UCHAR RefFrameMapTextureIndex[8]; 249 UINT32 upscaled_width; 250 UINT32 frame_to_show_map_idx; 251 UINT32 show_existing_frame; 252 UINT32 frame_tag_size; 253 UINT32 offset_to_dct_parts; 254 UCHAR skip_ref0; 255 UCHAR skip_ref1; 256 RK_U8 refresh_frame_flags; 257 void *cdfs; 258 void *cdfs_ndvc; 259 RK_U8 tile_cols_log2; 260 RK_U8 tile_rows_log2; 261 } DXVA_PicParams_AV1, *LPDXVA_PicParams_AV1; 262 263 typedef struct _DXVA_Slice_AV1_Short { 264 UINT BSNALunitDataLocation; 265 UINT SliceByteInBuffer; 266 USHORT wBadSliceChopping; 267 } DXVA_Slice_AV1_Short, *LPDXVA_Slice_AV1_Short; 268 269 #endif 270