1 /* 2 * 3 * Copyright 2015 Rockchip Electronics Co. LTD 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 19 #ifndef __H264D_SYNTAX_H__ 20 #define __H264D_SYNTAX_H__ 21 22 #include "h264_syntax.h" 23 #include "dxva_syntax.h" 24 25 /* H.264/AVC-specific structures */ 26 27 /* H.264/AVC picture entry data structure */ 28 typedef struct _DXVA_PicEntry_H264 { 29 union { 30 struct { 31 RK_U8 Index7Bits : 7; 32 RK_U8 AssociatedFlag : 1; 33 }; 34 RK_U8 bPicEntry; 35 }; 36 } DXVA_PicEntry_H264, *LPDXVA_PicEntry_H264; /* 1 byte */ 37 38 /* H.264/AVC picture parameters structure */ 39 typedef struct _DXVA_PicParams_H264 { 40 RK_U16 wFrameWidthInMbsMinus1; 41 RK_U16 wFrameHeightInMbsMinus1; 42 DXVA_PicEntry_H264 CurrPic; /* flag is bot field flag */ 43 RK_U8 num_ref_frames; 44 45 union { 46 struct { 47 RK_U16 field_pic_flag : 1; 48 RK_U16 MbaffFrameFlag : 1; 49 RK_U16 residual_colour_transform_flag : 1; 50 RK_U16 sp_for_switch_flag : 1; 51 RK_U16 chroma_format_idc : 2; 52 RK_U16 RefPicFlag : 1; 53 RK_U16 constrained_intra_pred_flag : 1; 54 55 RK_U16 weighted_pred_flag : 1; 56 RK_U16 weighted_bipred_idc : 2; 57 RK_U16 MbsConsecutiveFlag : 1; 58 RK_U16 frame_mbs_only_flag : 1; 59 RK_U16 transform_8x8_mode_flag : 1; 60 RK_U16 MinLumaBipredSize8x8Flag : 1; 61 RK_U16 IntraPicFlag : 1; 62 }; 63 RK_U16 wBitFields; 64 }; 65 RK_U8 bit_depth_luma_minus8; 66 RK_U8 bit_depth_chroma_minus8; 67 68 RK_U16 Reserved16Bits; 69 RK_U32 StatusReportFeedbackNumber; 70 71 DXVA_PicEntry_H264 RefFrameList[16]; /* flag LT */ 72 RK_S32 CurrFieldOrderCnt[2]; 73 RK_S32 FieldOrderCntList[16][2]; 74 75 RK_S8 pic_init_qs_minus26; 76 RK_S8 chroma_qp_index_offset; /* also used for QScb */ 77 RK_S8 second_chroma_qp_index_offset; /* also for QScr */ 78 RK_U8 ContinuationFlag; 79 80 /* remainder for parsing */ 81 RK_S8 pic_init_qp_minus26; 82 RK_U8 num_ref_idx_l0_active_minus1; 83 RK_U8 num_ref_idx_l1_active_minus1; 84 RK_U8 Reserved8BitsA; 85 86 RK_U16 FrameNumList[16]; 87 RK_U32 UsedForReferenceFlags; 88 RK_U16 NonExistingFrameFlags; 89 RK_U16 frame_num; 90 91 RK_U8 log2_max_frame_num_minus4; 92 RK_U8 pic_order_cnt_type; 93 RK_U8 log2_max_pic_order_cnt_lsb_minus4; 94 RK_U8 delta_pic_order_always_zero_flag; 95 96 RK_U8 direct_8x8_inference_flag; 97 RK_U8 entropy_coding_mode_flag; 98 RK_U8 pic_order_present_flag; 99 RK_U8 num_slice_groups_minus1; 100 101 RK_U8 slice_group_map_type; 102 RK_U8 deblocking_filter_control_present_flag; 103 RK_U8 redundant_pic_cnt_present_flag; 104 RK_U8 Reserved8BitsB; 105 106 RK_U16 slice_group_change_rate_minus1; 107 108 //RK_U8 SliceGroupMap[810]; /* 4b/sgmu, Size BT.601 */ 109 110 } DXVA_PicParams_H264, *LPDXVA_PicParams_H264; 111 112 /* H.264/AVC quantization weighting matrix data structure */ 113 typedef struct _DXVA_Qmatrix_H264 { 114 RK_U8 bScalingLists4x4[6][16]; 115 RK_U8 bScalingLists8x8[6][64]; 116 117 } DXVA_Qmatrix_H264, *LPDXVA_Qmatrix_H264; 118 119 /* H.264/AVC slice control data structure - short form */ 120 typedef struct _DXVA_Slice_H264_Short { 121 RK_U32 BSNALunitDataLocation; /* type 1..5 */ 122 RK_U32 SliceBytesInBuffer; /* for off-host parse */ 123 RK_U16 wBadSliceChopping; /* for off-host parse */ 124 } DXVA_Slice_H264_Short, *LPDXVA_Slice_H264_Short; 125 126 /* H.264/AVC picture entry data structure - long form */ 127 typedef struct _DXVA_Slice_H264_Long { 128 RK_U32 BSNALunitDataLocation; /* type 1..5 */ 129 RK_U32 SliceBytesInBuffer; /* for off-host parse */ 130 RK_U16 wBadSliceChopping; /* for off-host parse */ 131 132 RK_U16 first_mb_in_slice; 133 RK_U16 NumMbsForSlice; 134 135 136 RK_U8 slice_type; 137 RK_U8 num_ref_idx_l0_active_minus1; 138 RK_U8 num_ref_idx_l1_active_minus1; 139 DXVA_PicEntry_H264 RefPicList[3][32]; /* L0 & L1 */ 140 #if 0 141 RK_U16 BitOffsetToSliceData; /* after CABAC alignment */ 142 RK_U8 luma_log2_weight_denom; 143 RK_U8 chroma_log2_weight_denom; 144 RK_S8 slice_alpha_c0_offset_div2; 145 RK_S8 slice_beta_offset_div2; 146 RK_U8 Reserved8Bits; 147 RK_S16 Weights[2][32][3][2]; /* L0 & L1; Y, Cb, Cr */ 148 RK_S8 slice_qs_delta; 149 /* rest off-host parse */ 150 RK_S8 slice_qp_delta; 151 #endif 152 RK_U8 redundant_pic_cnt; 153 RK_U8 direct_spatial_mv_pred_flag; 154 RK_U8 cabac_init_idc; 155 RK_U8 disable_deblocking_filter_idc; 156 RK_U16 slice_id; 157 /* add parameter for setting hardware */ 158 RK_U32 active_sps_id; 159 RK_U32 active_pps_id; 160 RK_U32 idr_pic_id; 161 RK_U32 idr_flag; 162 RK_U32 drpm_used_bitlen; 163 RK_U32 poc_used_bitlen; 164 RK_U32 nal_ref_idc; 165 RK_U32 profileIdc; 166 } DXVA_Slice_H264_Long, *LPDXVA_Slice_H264_Long; 167 168 /* H.264/AVC macro block control command data structure */ 169 typedef struct _DXVA_MBctrl_H264 { 170 union { 171 struct { 172 RK_U32 bSliceID : 8; /* 1 byte */ 173 RK_U32 MbType5Bits : 5; 174 RK_U32 IntraMbFlag : 1; 175 RK_U32 mb_field_decoding_flag : 1; 176 RK_U32 transform_size_8x8_flag : 1; /* 2 bytes */ 177 RK_U32 HostResidDiff : 1; 178 RK_U32 DcBlockCodedCrFlag : 1; 179 RK_U32 DcBlockCodedCbFlag : 1; 180 RK_U32 DcBlockCodedYFlag : 1; 181 RK_U32 FilterInternalEdgesFlag : 1; 182 RK_U32 FilterLeftMbEdgeFlag : 1; 183 RK_U32 FilterTopMbEdgeFlag : 1; 184 RK_U32 ReservedBit : 1; 185 RK_U32 bMvQuantity : 8; /* 4 bytes */ 186 }; 187 RK_U32 dwMBtype; /* 4 bytes so far */ 188 }; 189 RK_U16 CurrMbAddr; /* 6 bytes so far */ 190 RK_U16 wPatternCode[3];/* YCbCr, 16 4x4 blks, 1b each */ 191 /* 12 bytes so far */ 192 RK_U8 bQpPrime[3]; /* Y, Cb, Cr, need just 7b QpY */ 193 RK_U8 bMBresidDataQuantity; 194 RK_U32 dwMBdataLocation; /* offset into resid buffer */ 195 /* 20 bytes so far */ 196 union { 197 struct { 198 /* start here for Intra MB's (9 useful bytes in branch) */ 199 RK_U16 LumaIntraPredModes[4];/* 16 blocks, 4b each */ 200 /* 28 bytes so far */ 201 union { 202 struct { 203 RK_U8 intra_chroma_pred_mode : 2; 204 RK_U8 IntraPredAvailFlags : 5; 205 RK_U8 ReservedIntraBit : 1; 206 }; 207 RK_U8 bMbIntraStruct; /* 29 bytes so far */ 208 }; 209 RK_U8 ReservedIntra24Bits[3]; /* 32 bytes total */ 210 }; 211 struct { 212 /* start here for non-Intra MB's (12 bytes in branch) */ 213 RK_U8 bSubMbShapes; /* 4 subMbs, 2b each */ 214 RK_U8 bSubMbPredModes; /* 4 subMBs, 2b each */ 215 /* 22 bytes so far */ 216 RK_U16 wMvBuffOffset; /* offset into MV buffer */ 217 RK_U8 bRefPicSelect[2][4]; /* 32 bytes total */ 218 }; 219 }; 220 } DXVA_MBctrl_H264, *LPDXVA_MBctrl_H264; 221 222 /* H.264/AVC IndexA and IndexB data structure */ 223 typedef struct _DXVA_DeblockIndexAB_H264 { 224 RK_U8 bIndexAinternal; /* 6b - could get from MB CC */ 225 RK_U8 bIndexBinternal; /* 6b - could get from MB CC */ 226 227 RK_U8 bIndexAleft0; 228 RK_U8 bIndexBleft0; 229 230 RK_U8 bIndexAleft1; 231 RK_U8 bIndexBleft1; 232 233 RK_U8 bIndexAtop0; 234 RK_U8 bIndexBtop0; 235 236 RK_U8 bIndexAtop1; 237 RK_U8 bIndexBtop1; 238 } DXVA_DeblockIndexAB_H264, *LPDXVA_DeblockIndexAB_H264; 239 /* 10 bytes in struct */ 240 241 /* H.264/AVC deblocking filter control data structure */ 242 typedef struct _DXVA_Deblock_H264 { 243 RK_U16 CurrMbAddr; /* dup info */ /* 2 bytes so far */ 244 union { 245 struct { 246 RK_U8 ReservedBit : 1; 247 RK_U8 FieldModeCurrentMbFlag : 1; /* dup info */ 248 RK_U8 FieldModeLeftMbFlag : 1; 249 RK_U8 FieldModeAboveMbFlag : 1; 250 RK_U8 FilterInternal8x8EdgesFlag : 1; 251 RK_U8 FilterInternal4x4EdgesFlag : 1; 252 RK_U8 FilterLeftMbEdgeFlag : 1; 253 RK_U8 FilterTopMbEdgeFlag : 1; 254 }; 255 RK_U8 FirstByte; 256 }; 257 RK_U8 Reserved8Bits; /* 4 bytes so far */ 258 259 RK_U8 bbSinternalLeftVert; /* 2 bits per bS */ 260 RK_U8 bbSinternalMidVert; 261 262 RK_U8 bbSinternalRightVert; 263 RK_U8 bbSinternalTopHorz; /* 8 bytes so far */ 264 265 RK_U8 bbSinternalMidHorz; 266 RK_U8 bbSinternalBotHorz; /* 10 bytes so far */ 267 268 RK_U16 wbSLeft0; /* 4 bits per bS (1 wasted) */ 269 RK_U16 wbSLeft1; /* 4 bits per bS (1 wasted) */ 270 271 RK_U16 wbSTop0; /* 4 bits per bS (1 wasted) */ 272 RK_U16 wbSTop1; /* 4b (2 wasted) 18 bytes so far*/ 273 274 DXVA_DeblockIndexAB_H264 IndexAB[3]; /* Y, Cb, Cr */ 275 276 } DXVA_Deblock_H264, *LPDXVA_Deblock_H264;/* 48 bytes */ 277 278 /* H.264/AVC film grain characteristics data structure */ 279 typedef struct _DXVA_FilmGrainCharacteristics { 280 281 RK_U16 wFrameWidthInMbsMinus1; 282 RK_U16 wFrameHeightInMbsMinus1; 283 284 DXVA_PicEntry_H264 InPic; /* flag is bot field flag */ 285 DXVA_PicEntry_H264 OutPic; /* flag is field pic flag */ 286 287 RK_U16 PicOrderCnt_offset; 288 RK_S32 CurrPicOrderCnt; 289 RK_U32 StatusReportFeedbackNumber; 290 291 RK_U8 model_id; 292 RK_U8 separate_colour_description_present_flag; 293 RK_U8 film_grain_bit_depth_luma_minus8; 294 RK_U8 film_grain_bit_depth_chroma_minus8; 295 296 RK_U8 film_grain_full_range_flag; 297 RK_U8 film_grain_colour_primaries; 298 RK_U8 film_grain_transfer_characteristics; 299 RK_U8 film_grain_matrix_coefficients; 300 301 RK_U8 blending_mode_id; 302 RK_U8 log2_scale_factor; 303 304 RK_U8 comp_model_present_flag[4]; 305 RK_U8 num_intensity_intervals_minus1[4]; 306 RK_U8 num_model_values_minus1[4]; 307 308 RK_U8 intensity_interval_lower_bound[3][16]; 309 RK_U8 intensity_interval_upper_bound[3][16]; 310 RK_S16 comp_model_value[3][16][8]; 311 } DXVA_FilmGrainChar_H264, *LPDXVA_FilmGrainChar_H264; 312 313 /* H.264/AVC status reporting data structure */ 314 typedef struct _DXVA_Status_H264 { 315 RK_U32 StatusReportFeedbackNumber; 316 DXVA_PicEntry_H264 CurrPic; /* flag is bot field flag */ 317 RK_U8 field_pic_flag; 318 RK_U8 bDXVA_Func; 319 RK_U8 bBufType; 320 RK_U8 bStatus; 321 RK_U8 bReserved8Bits; 322 RK_U16 wNumMbsAffected; 323 } DXVA_Status_H264, *LPDXVA_Status_H264; 324 325 /* H.264 MVC picture parameters structure */ 326 typedef struct _DXVA_PicParams_H264_MVC { 327 RK_U16 wFrameWidthInMbsMinus1; 328 RK_U16 wFrameHeightInMbsMinus1; 329 DXVA_PicEntry_H264 CurrPic; /* flag is bot field flag */ 330 RK_U8 num_ref_frames; 331 332 union { 333 struct { 334 RK_U16 field_pic_flag : 1; 335 RK_U16 MbaffFrameFlag : 1; 336 RK_U16 residual_colour_transform_flag : 1; 337 RK_U16 sp_for_switch_flag : 1; 338 RK_U16 chroma_format_idc : 2; 339 RK_U16 RefPicFlag : 1; 340 RK_U16 constrained_intra_pred_flag : 1; 341 342 RK_U16 weighted_pred_flag : 1; 343 RK_U16 weighted_bipred_idc : 2; 344 RK_U16 MbsConsecutiveFlag : 1; 345 RK_U16 frame_mbs_only_flag : 1; 346 RK_U16 transform_8x8_mode_flag : 1; 347 RK_U16 MinLumaBipredSize8x8Flag : 1; 348 RK_U16 IntraPicFlag : 1; 349 }; 350 RK_U16 wBitFields; 351 }; 352 RK_U8 bit_depth_luma_minus8; 353 RK_U8 bit_depth_chroma_minus8; 354 355 RK_U16 Reserved16Bits; 356 RK_U32 StatusReportFeedbackNumber; 357 358 DXVA_PicEntry_H264 RefFrameList[16]; /* flag LT */ 359 RK_S32 CurrFieldOrderCnt[2]; 360 RK_S32 FieldOrderCntList[16][2]; 361 362 RK_S8 pic_init_qs_minus26; 363 RK_S8 chroma_qp_index_offset; /* also used for QScb */ 364 RK_S8 second_chroma_qp_index_offset; /* also for QScr */ 365 RK_U8 ContinuationFlag; 366 367 /* remainder for parsing */ 368 RK_S8 pic_init_qp_minus26; 369 RK_U8 num_ref_idx_l0_active_minus1; 370 RK_U8 num_ref_idx_l1_active_minus1; 371 RK_U8 Reserved8BitsA; 372 373 RK_U16 FrameNumList[16]; 374 RK_U16 LongTermPicNumList[16]; 375 RK_U32 UsedForReferenceFlags; 376 RK_U16 NonExistingFrameFlags; 377 RK_U16 frame_num; 378 379 RK_U8 log2_max_frame_num_minus4; 380 RK_U8 pic_order_cnt_type; 381 RK_U8 log2_max_pic_order_cnt_lsb_minus4; 382 RK_U8 delta_pic_order_always_zero_flag; 383 384 RK_U8 direct_8x8_inference_flag; 385 RK_U8 entropy_coding_mode_flag; 386 RK_U8 pic_order_present_flag; 387 RK_U8 num_slice_groups_minus1; 388 389 RK_U8 slice_group_map_type; 390 RK_U8 deblocking_filter_control_present_flag; 391 RK_U8 redundant_pic_cnt_present_flag; 392 RK_U8 Reserved8BitsB; 393 /* SliceGroupMap is not needed for MVC, as MVC is for high profile only */ 394 RK_U16 slice_group_change_rate_minus1; 395 /* Following are H.264 MVC Specific parameters */ 396 RK_S8 num_views_minus1; 397 RK_U16 view_id[16]; 398 RK_U8 num_anchor_refs_l0[16]; 399 RK_U16 anchor_ref_l0[16][16]; 400 RK_U8 num_anchor_refs_l1[16]; 401 RK_U16 anchor_ref_l1[16][16]; 402 RK_U8 num_non_anchor_refs_l0[16]; 403 RK_U16 non_anchor_ref_l0[16][16]; 404 RK_U8 num_non_anchor_refs_l1[16]; 405 RK_U16 non_anchor_ref_l1[16][16]; 406 407 RK_U16 curr_view_id; 408 RK_U8 anchor_pic_flag; 409 RK_U8 inter_view_flag; 410 RK_U16 ViewIDList[16]; 411 //!< add in Rock-Chip RKVDEC IP 412 RK_U16 curr_layer_id; 413 RK_U16 RefPicColmvUsedFlags; 414 RK_U16 RefPicFiledFlags; 415 RK_U8 RefPicLayerIdList[16]; 416 RK_U8 scaleing_list_enable_flag; 417 RK_U16 UsedForInTerviewflags; 418 419 //!< extensive 420 RK_U32 spspps_update; 421 422 //!< for fpga test 423 RK_U16 seq_parameter_set_id; 424 RK_U16 pps_seq_parameter_set_id; 425 RK_U16 pps_pic_parameter_set_id; 426 RK_U16 profile_idc; 427 RK_U8 constraint_set3_flag; 428 RK_U8 qpprime_y_zero_transform_bypass_flag; 429 RK_U8 mvc_extension_enable; 430 431 } DXVA_PicParams_H264_MVC, *LPDXVA_PicParams_H264_MVC; 432 433 434 435 typedef struct h264d_syntax_t { 436 RK_U32 num; 437 DXVA2_DecodeBufferDesc *buf; 438 } H264dSyntax_t; 439 440 #endif /*__H264D_SYNTAX_H__*/ 441 442