xref: /rockchip-linux_mpp/mpp/common/h265d_syntax.h (revision 437bfbeb9567cca9cd9080e3f6954aa9d6a94f18)
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  * @file       h265d_syntax.h
20  * @brief
21  * @author      csy(csy@rock-chips.com)
22 
23  * @version     1.0.0
24  * @history
25  *   2015.7.15 : Create
26  */
27 #ifndef __H265D_SYNTAX__
28 #define __H265D_SYNTAX__
29 typedef unsigned long       DWORD;
30 typedef unsigned char       BYTE;
31 typedef unsigned short      WORD;
32 typedef unsigned long       ULONG;
33 typedef unsigned short      USHORT;
34 typedef unsigned char       UCHAR;
35 typedef unsigned int        UINT;
36 typedef unsigned int        UINT32;
37 
38 typedef signed   int        BOOL;
39 typedef signed   int        INT;
40 typedef signed   char       CHAR;
41 typedef signed   short      SHORT;
42 typedef signed   long       LONG;
43 typedef void               *PVOID;
44 
45 /* HEVC Picture Entry structure */
46 #define MAX_SLICES 600
47 typedef struct _DXVA_PicEntry_HEVC {
48     union {
49         struct {
50             UCHAR Index7Bits : 7;
51             UCHAR AssociatedFlag : 1;
52         };
53         UCHAR bPicEntry;
54     };
55 } DXVA_PicEntry_HEVC, *LPDXVA_PicEntry_HEVC;
56 
57 typedef struct _Short_SPS_RPS_HEVC {
58     UCHAR num_negative_pics;
59     UCHAR num_positive_pics;
60     SHORT delta_poc_s0[16];
61     UCHAR s0_used_flag[16];
62     SHORT delta_poc_s1[16];
63     UCHAR  s1_used_flag[16];
64 } Short_SPS_RPS_HEVC;
65 
66 typedef struct _LT_SPS_RPS_HEVC {
67     USHORT lt_ref_pic_poc_lsb;
68     UCHAR  used_by_curr_pic_lt_flag;
69 } LT_SPS_RPS_HEVC;
70 /* HEVC Picture Parameter structure */
71 typedef struct _DXVA_PicParams_HEVC {
72     USHORT      PicWidthInMinCbsY;
73     USHORT      PicHeightInMinCbsY;
74     union {
75         struct {
76             USHORT  chroma_format_idc                       : 2;
77             USHORT  separate_colour_plane_flag              : 1;
78             USHORT  bit_depth_luma_minus8                   : 3;
79             USHORT  bit_depth_chroma_minus8                 : 3;
80             USHORT  log2_max_pic_order_cnt_lsb_minus4       : 4;
81             USHORT  NoPicReorderingFlag                     : 1;
82             USHORT  NoBiPredFlag                            : 1;
83             USHORT  ReservedBits1                            : 1;
84         };
85         USHORT wFormatAndSequenceInfoFlags;
86     };
87     DXVA_PicEntry_HEVC  CurrPic;
88     UCHAR   sps_max_dec_pic_buffering_minus1;
89     UCHAR   log2_min_luma_coding_block_size_minus3;
90     UCHAR   log2_diff_max_min_luma_coding_block_size;
91     UCHAR   log2_min_transform_block_size_minus2;
92     UCHAR   log2_diff_max_min_transform_block_size;
93     UCHAR   max_transform_hierarchy_depth_inter;
94     UCHAR   max_transform_hierarchy_depth_intra;
95     UCHAR   num_short_term_ref_pic_sets;
96     UCHAR   num_long_term_ref_pics_sps;
97     UCHAR   num_ref_idx_l0_default_active_minus1;
98     UCHAR   num_ref_idx_l1_default_active_minus1;
99     CHAR    init_qp_minus26;
100     UCHAR   ucNumDeltaPocsOfRefRpsIdx;
101     USHORT  wNumBitsForShortTermRPSInSlice;
102     USHORT  ReservedBits2;
103 
104     union {
105         struct {
106             UINT32  scaling_list_enabled_flag                    : 1;
107             UINT32  amp_enabled_flag                            : 1;
108             UINT32  sample_adaptive_offset_enabled_flag         : 1;
109             UINT32  pcm_enabled_flag                            : 1;
110             UINT32  pcm_sample_bit_depth_luma_minus1            : 4;
111             UINT32  pcm_sample_bit_depth_chroma_minus1          : 4;
112             UINT32  log2_min_pcm_luma_coding_block_size_minus3  : 2;
113             UINT32  log2_diff_max_min_pcm_luma_coding_block_size : 2;
114             UINT32  pcm_loop_filter_disabled_flag                : 1;
115             UINT32  long_term_ref_pics_present_flag             : 1;
116             UINT32  sps_temporal_mvp_enabled_flag               : 1;
117             UINT32  strong_intra_smoothing_enabled_flag         : 1;
118             UINT32  dependent_slice_segments_enabled_flag       : 1;
119             UINT32  output_flag_present_flag                    : 1;
120             UINT32  num_extra_slice_header_bits                 : 3;
121             UINT32  sign_data_hiding_enabled_flag               : 1;
122             UINT32  cabac_init_present_flag                     : 1;
123             UINT32  ReservedBits3                               : 5;
124         };
125         UINT32 dwCodingParamToolFlags;
126     };
127 
128     union {
129         struct {
130             UINT32  constrained_intra_pred_flag                 : 1;
131             UINT32  transform_skip_enabled_flag                 : 1;
132             UINT32  cu_qp_delta_enabled_flag                    : 1;
133             UINT32  pps_slice_chroma_qp_offsets_present_flag    : 1;
134             UINT32  weighted_pred_flag                          : 1;
135             UINT32  weighted_bipred_flag                        : 1;
136             UINT32  transquant_bypass_enabled_flag              : 1;
137             UINT32  tiles_enabled_flag                          : 1;
138             UINT32  entropy_coding_sync_enabled_flag            : 1;
139             UINT32  uniform_spacing_flag                        : 1;
140             UINT32  loop_filter_across_tiles_enabled_flag       : 1;
141             UINT32  pps_loop_filter_across_slices_enabled_flag  : 1;
142             UINT32  deblocking_filter_override_enabled_flag     : 1;
143             UINT32  pps_deblocking_filter_disabled_flag         : 1;
144             UINT32  lists_modification_present_flag             : 1;
145             UINT32  slice_segment_header_extension_present_flag : 1;
146             UINT32  IrapPicFlag                                 : 1;
147             UINT32  IdrPicFlag                                  : 1;
148             UINT32  IntraPicFlag                                : 1;
149             // sps exension flags
150             UINT32  sps_extension_flag                          : 1;
151             UINT32  sps_range_extension_flag                    : 1;
152             UINT32  transform_skip_rotation_enabled_flag        : 1;
153             UINT32  transform_skip_context_enabled_flag         : 1;
154             UINT32  implicit_rdpcm_enabled_flag                 : 1;
155             UINT32  explicit_rdpcm_enabled_flag                 : 1;
156             UINT32  extended_precision_processing_flag          : 1;
157             UINT32  intra_smoothing_disabled_flag               : 1;
158             UINT32  high_precision_offsets_enabled_flag         : 1;
159             UINT32  persistent_rice_adaptation_enabled_flag     : 1;
160             UINT32  cabac_bypass_alignment_enabled_flag         : 1;
161             // pps exension flags
162             UINT32  cross_component_prediction_enabled_flag     : 1;
163             UINT32  chroma_qp_offset_list_enabled_flag          : 1;
164         };
165         UINT32 dwCodingSettingPicturePropertyFlags;
166     };
167     CHAR    pps_cb_qp_offset;
168     CHAR    pps_cr_qp_offset;
169     UCHAR   num_tile_columns_minus1;
170     UCHAR   num_tile_rows_minus1;
171     USHORT  column_width_minus1[19];
172     USHORT  row_height_minus1[21];
173     UCHAR   diff_cu_qp_delta_depth;
174     CHAR    pps_beta_offset_div2;
175     CHAR    pps_tc_offset_div2;
176     UCHAR   log2_parallel_merge_level_minus2;
177     INT     CurrPicOrderCntVal;
178     DXVA_PicEntry_HEVC  RefPicList[15];
179     UCHAR   ReservedBits5;
180     INT     PicOrderCntValList[15];
181     UCHAR   RefPicSetStCurrBefore[8];
182     UCHAR   RefPicSetStCurrAfter[8];
183     UCHAR   RefPicSetLtCurr[8];
184     USHORT  ReservedBits6;
185     USHORT  ReservedBits7;
186     UINT    StatusReportFeedbackNumber;
187     UINT32 vps_id;
188     UINT32 pps_id;
189     UINT32 sps_id;
190     INT    current_poc;
191 
192     Short_SPS_RPS_HEVC cur_st_rps;
193     Short_SPS_RPS_HEVC sps_st_rps[64];
194     LT_SPS_RPS_HEVC    sps_lt_rps[32];
195 
196     // PPS exentison
197     UCHAR log2_max_transform_skip_block_size;
198     UCHAR diff_cu_chroma_qp_offset_depth;
199     CHAR  cb_qp_offset_list[6];
200     CHAR  cr_qp_offset_list[6];
201     UCHAR chroma_qp_offset_list_len_minus1;
202 
203     UCHAR  scaling_list_data_present_flag;
204     UCHAR  ps_update_flag;
205     UCHAR  rps_update_flag;
206 } DXVA_PicParams_HEVC, *LPDXVA_PicParams_HEVC;
207 
208 /* HEVC Quantizatiuon Matrix structure */
209 typedef struct _DXVA_Qmatrix_HEVC {
210     UCHAR ucScalingLists0[6][16];
211     UCHAR ucScalingLists1[6][64];
212     UCHAR ucScalingLists2[6][64];
213     UCHAR ucScalingLists3[2][64];
214     UCHAR ucScalingListDCCoefSizeID2[6];
215     UCHAR ucScalingListDCCoefSizeID3[2];
216 } DXVA_Qmatrix_HEVC, *LPDXVA_Qmatrix_HEVC;
217 
218 
219 /* HEVC Slice Control Structure */
220 typedef struct _DXVA_Slice_HEVC_Short {
221     UINT    BSNALunitDataLocation;
222     UINT    SliceBytesInBuffer;
223     USHORT  wBadSliceChopping;
224 } DXVA_Slice_HEVC_Short, *LPDXVA_Slice_HEVC_Short;
225 
226 /* just use in the case of pps->slice_header_extension_present_flag is 1 */
227 typedef struct _DXVA_Slice_HEVC_Cut_Param {
228     UINT    start_bit;
229     UINT    end_bit;
230     USHORT  is_enable;
231 } DXVA_Slice_HEVC_Cut_Param, *LPDXVA_Slice_HEVC_Cut_Param;
232 
233 typedef struct h265d_dxva2_picture_context {
234     DXVA_PicParams_HEVC         pp;
235     DXVA_Qmatrix_HEVC           qm;
236     UINT32                      slice_count;
237     DXVA_Slice_HEVC_Short       *slice_short;
238     const UCHAR                 *bitstream;
239     UINT32                      bitstream_size;
240     DXVA_Slice_HEVC_Cut_Param   *slice_cut_param;
241     INT                         max_slice_num;
242 } h265d_dxva2_picture_context_t;
243 
244 #endif /*__H265D_SYNTAX__*/
245