xref: /OK3568_Linux_fs/external/mpp/mpp/common/h265d_syntax.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
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             UINT32  ReservedBits4                               : 13;
150         };
151         UINT32 dwCodingSettingPicturePropertyFlags;
152     };
153     CHAR    pps_cb_qp_offset;
154     CHAR    pps_cr_qp_offset;
155     UCHAR   num_tile_columns_minus1;
156     UCHAR   num_tile_rows_minus1;
157     USHORT  column_width_minus1[19];
158     USHORT  row_height_minus1[21];
159     UCHAR   diff_cu_qp_delta_depth;
160     CHAR    pps_beta_offset_div2;
161     CHAR    pps_tc_offset_div2;
162     UCHAR   log2_parallel_merge_level_minus2;
163     INT     CurrPicOrderCntVal;
164     DXVA_PicEntry_HEVC  RefPicList[15];
165     UCHAR   ReservedBits5;
166     INT     PicOrderCntValList[15];
167     UCHAR   RefPicSetStCurrBefore[8];
168     UCHAR   RefPicSetStCurrAfter[8];
169     UCHAR   RefPicSetLtCurr[8];
170     USHORT  ReservedBits6;
171     USHORT  ReservedBits7;
172     UINT    StatusReportFeedbackNumber;
173     UINT32 vps_id;
174     UINT32 pps_id;
175     UINT32 sps_id;
176     INT    current_poc;
177 
178     Short_SPS_RPS_HEVC sps_st_rps[64];
179     LT_SPS_RPS_HEVC    sps_lt_rps[32];
180 
181     UCHAR  scaling_list_data_present_flag;
182     UCHAR  ps_update_flag;
183 } DXVA_PicParams_HEVC, *LPDXVA_PicParams_HEVC;
184 
185 /* HEVC Quantizatiuon Matrix structure */
186 typedef struct _DXVA_Qmatrix_HEVC {
187     UCHAR ucScalingLists0[6][16];
188     UCHAR ucScalingLists1[6][64];
189     UCHAR ucScalingLists2[6][64];
190     UCHAR ucScalingLists3[2][64];
191     UCHAR ucScalingListDCCoefSizeID2[6];
192     UCHAR ucScalingListDCCoefSizeID3[2];
193 } DXVA_Qmatrix_HEVC, *LPDXVA_Qmatrix_HEVC;
194 
195 
196 /* HEVC Slice Control Structure */
197 typedef struct _DXVA_Slice_HEVC_Short {
198     UINT    BSNALunitDataLocation;
199     UINT    SliceBytesInBuffer;
200     USHORT  wBadSliceChopping;
201 } DXVA_Slice_HEVC_Short, *LPDXVA_Slice_HEVC_Short;
202 
203 /* just use in the case of pps->slice_header_extension_present_flag is 1 */
204 typedef struct _DXVA_Slice_HEVC_Cut_Param {
205     UINT    start_bit;
206     UINT    end_bit;
207     USHORT  is_enable;
208 } DXVA_Slice_HEVC_Cut_Param, *LPDXVA_Slice_HEVC_Cut_Param;
209 
210 typedef struct h265d_dxva2_picture_context {
211     DXVA_PicParams_HEVC         pp;
212     DXVA_Qmatrix_HEVC           qm;
213     UINT32                      slice_count;
214     DXVA_Slice_HEVC_Short       *slice_short;
215     const UCHAR                 *bitstream;
216     UINT32                      bitstream_size;
217     DXVA_Slice_HEVC_Cut_Param   *slice_cut_param;
218     INT                         max_slice_num;
219 } h265d_dxva2_picture_context_t;
220 
221 #endif /*__H265D_SYNTAX__*/
222