• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  * Copyright (C) 2022 The Android Open Source Project
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  * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19  */
20 /*!
21  **************************************************************************
22  * \file isvcd_nal_structs.h
23  *
24  * \brief
25  *    Contains the definitions of structures used in NAL processing
26  *
27  * Detailed_description
28  *
29  * \date
30  *
31  *
32  * \author : Kishore
33  **************************************************************************
34  */
35 
36 #ifndef _SVCD_NAL_STRUCTS_H_
37 #define _SVCD_NAL_STRUCTS_H_
38 
39 /*****************************************************************************/
40 /* File Includes                                                             */
41 /*****************************************************************************/
42 
43 /*****************************************************************************/
44 /* Constant Macros                                                           */
45 /*****************************************************************************/
46 
47 #define MAX_NUM_SLICE_GRPS_IN_LYR 8
48 
49 #define MAX_NUM_PACKETS_IN_NAL                    \
50     100 /*! Maximum number of packets that can be \
51   present in a NAL unit */
52 
53 /*****************************************************************************/
54 /* Function Macros                                                           */
55 /*****************************************************************************/
56 #define SLICE_PARSE_ERR_HDLR(i4_error, u4_err_code, pu4_err_code) \
57     if(0 != i4_error)                                             \
58     {                                                             \
59         *pu4_err_code = u4_err_code;                              \
60         return (NOT_OK);                                          \
61     }
62 
63 #define SLICE_PARSE_ERR_HDLR1(i4_error, u4_err_code, pu4_err_code, pi4_sps_pps, i4_sps_pps_err) \
64     if(0 != i4_error)                                                                           \
65     {                                                                                           \
66         *pu4_err_code = u4_err_code;                                                            \
67         *pi4_sps_pps = i4_sps_pps_err;                                                          \
68         return (NOT_OK);                                                                        \
69     }
70 
71 /*****************************************************************************/
72 /* Typedefs                                                                  */
73 /*****************************************************************************/
74 
75 /*****************************************************************************/
76 /* Enums                                                                     */
77 /*****************************************************************************/
78 
79 typedef enum
80 {
81     NAL_DISCARD_RESET_STATE,
82     NAL_DISCARD_ACTIVE_STATE
83 } NAL_DISCARD_STATE_MACHINE_T;
84 
85 /*****************************************************************************/
86 /* Structure                                                                 */
87 /*****************************************************************************/
88 
89 typedef struct
90 {
91     WORD32 i4_dependency_id; /*!< Target dependency id */
92     WORD32 i4_quality_id;    /*!< Target quality id */
93     WORD32 i4_temporal_id;   /*!< Target temporal id */
94     WORD32 i4_priority_id;   /*!< Target priority id */
95 } target_lyr_attr_t;
96 
97 typedef struct
98 {
99     WORD32 i4_num_bufs;  /*!< Number of buffers that comprises this NAL unit.
100       In case of Annex B based input, this value will always be 1. Otherwise
101       (RFC - input), this value indicates number of packets in the NAL unit
102       in the current process call                                              */
103 
104     UWORD8 *pu1_bufs;    /*!< Nal unit buffer pointer                           */
105     WORD32 i4_buf_sizes; /*!< Nal unit buffer size                            */
106 
107 } nal_unit_t;
108 
109 typedef struct
110 {
111     WORD32 i4_state;          /*!< State of emulation prevention in the state machine */
112     WORD32 i4_zeroes_cnt;     /*!< Number of consecutive zeroes counter */
113     UWORD32 u4_word;          /*!< Place holder for WORD - output */
114     UWORD32 u4_bytes_in_word; /*!< Number of bytes in the WORD */
115 } emulation_prevent_ctxt_t;
116 
117 typedef struct vcl_buf_hdr_t
118 {
119     struct vcl_buf_hdr_t *ps_next; /*!< Pointer to next VCL NAL buffer header.
120                           This will be poiting to next slice in the layer. This
121                           field shall be set to NULL for the last slice
122                           (VCL NAL) in a layer */
123 
124     UWORD32 u4_max_bits;           /*!< Total number of SODB bits present in the VCL
125                                    NAL (slice)*/
126 
127     WORD32 i4_buf_offset;          /*!< This is the offset from the start of the
128                                    VCL NAL header to start of SODB data of VCL NAL.
129                                    This shall be multiple of 4*/
130 
131     WORD32 i4_slice_offset;        /*!< It is the offset from start of VCL NAL data
132                                    to start of slice data. A value of 0 shall
133                                    indicate that prefix NAL unit is
134                                    not present
135                                    Note: If prefix NAL unit is present then it will
136                                    be present between the offsets "i4_buf_offset" to
137                                    "i4_slice_offset"*/
138 
139     UWORD32 u4_prefix_nal_bits;    /*!< Total number of SODB bits present in the VCL
140                             NAL (slice). This shall have valid value when
141                            "i4_slice_offset" has non zero value
142                             */
143 
144     WORD32 i4_no_int_lyr_pred;     /*!< The value of no inter layer prediction
145                             which is decoded from the NAL header
146                             */
147 
148     WORD32 i4_first_mb_addr;       /*!< The 'first_mb_address' syntax
149                                    element value decoded form the slice
150                                    header present in the VCL NAL
151                                    */
152 } vcl_buf_hdr_t;
153 
154 typedef struct non_vcl_buf_hdr_t
155 {
156     struct non_vcl_buf_hdr_t *ps_next; /*!< This shall point to start of next NON
157                           VCL buffer header that is extracted from the bitstream.
158                           It shall be set to NULL for the last non VCL NAL
159                            */
160 
161     WORD32 i4_nal_unit_type;           /*!< NAL unit type that is decoded from the NAL
162                                        header
163                                       */
164 
165     WORD32 i4_buf_offset;              /*!< This is the offset from the start of the
166                                             VCL NAL header to start of SODB data of VCL NAL.
167                                             This shall be multiple of 4
168                                          */
169 
170     WORD32 i4_buf_size;                /*!< Size of the NON VCL SODB data in bytes
171                                         */
172 
173 } non_vcl_buf_hdr_t;
174 typedef struct vcl_node_t
175 {
176     struct vcl_node_t *ps_top_node; /*!< Pointer to top node present in the DQID
177                                     list. This node is actually is a layer using
178                                     the current layer as a reference layer. Value
179                                     of NULL shall indicate that no more layers
180                                     with DQID higher than current layer is present
181                                     in the current access unit */
182 
183     struct vcl_node_t *ps_bot_node; /*!< Pointer to bottom node present in the
184                                       DQID list. This node is actually the
185                                       reference layer of the current layer. Value
186                                       of NULL shall indicate that no more layers
187                                       with DQID lower than current layer is
188                                       present in the current access unit */
189 
190     /*------ info part -------*/
191 
192     WORD32 i4_quality_id;    /*!< Quality id of the layer */
193 
194     WORD32 i4_dependency_id; /*!< Dependency id of the layer */
195 
196     WORD32 i4_temporal_id;   /*!< Temporal id of the layer */
197 
198     WORD32 i4_priority_id;   /*!< Priority id of the layer */
199 
200     WORD32 i4_idr_pic_flag;  /*!< Flag indicating whether current layer is
201                                   Idr picture or not. SVCD_TRUE shall indicate
202                                   the idr picture
203                               */
204 
205     WORD32 i4_nal_unit_type; /*!< NAL unit type of all slices in the current
206                                   picture
207                               */
208 
209     WORD32
210     i4_nal_ref_idc;                      /*!< NAL ref idc of all slices in the current picture */
211 
212     WORD32 i4_use_ref_base;              /*!< Use ref base flag of NAL header. */
213 
214     UWORD8 u1_sps_id;                    /*!< It shall have the value of SPS id used by this layer.
215                                              It's range is [0,63]
216                                           */
217 
218     UWORD8 u1_pps_id;                    /*!< It shall have the value of PPS id used by this layer.
219                                              It's range is [0,255]
220                                           */
221     UWORD8 u1_acc_no_int_pred;           /*! The value of accumulated no inter layer
222                                             prediction flag. This value will be "logical and
223                                             " of no inter layer prediction flag of all the
224                                             slices in the corresponding DQID
225                                           */
226 
227     UWORD16 u2_frm_num;                  /*!< It is the value of frame number of the layer.
228                                           */
229 
230     UWORD32 i4_idr_pic_num;              /*!< It shall have the value of IDR picture number when
231                                             "i4_idr_pic_flag" is SVCD_TRUE
232                                          */
233 
234     WORD32 i4_poc_syntax;                /*!< It shall have either "picture order cnt lsb" or
235                                          "delta picture order cnt [0]" that is decoded from the
236                                          slice header. When picture order coutn type is 0 then
237                                          this field holds "picture order cnt lsb" and when
238                                          picture order cnt type is 1 then this field holds
239                                          "delta picture order cnt [0]". This field will not
240                                          have a valid value when picture order cnt type is 2
241                                          */
242 
243     WORD32 i4_res_change_flag;           /*!< 'SpatialResolutionChangeFlag' for the
244                                               layer as specified in section G.7.4.3.4
245                                               Value 'SVCD_TRUE' indicates that parameter
246                                               'SpatialResolutionChangeFlag' is set to 1.
247                                               Otherwise it shall be set to SVCD_FALSE.
248                                               @sa SVCD_BOOL_T
249                                           */
250     WORD32 i4_ref_dq_id;                 /*!< reference layer DQid for current layer */
251 
252     WORD32 i4_num_slices;                /*!< Number of slices in the current layer */
253 
254     WORD32 i4_inter_lyr_dblk_idc;        /*!< Deblock filter idc for inter layer
255                                         deblocking. This shall be valid only
256                                         for layer with quality id = 0.
257                                         */
258     WORD32 i4_inter_lyr_alpha_c0_offset; /*!< Alpha C0 offset for inter layer
259                                  deblocking. This shall be valid only for
260                                  layers with quality id = 0.
261                                  */
262     WORD32 i4_inter_lyr_beta_offset;     /*!< Beta offset for inter layer
263                                      deblocking. This shall be valid only for
264                                      layers with quality id = 0.
265                                      */
266 
267     vcl_buf_hdr_t *ps_first_vcl_nal;     /*!< This shall point to start of the
268                                    VCL NAL header of the first slice (VCL NAL)
269                                    in a layer.
270                                    */
271 
272     vcl_buf_hdr_t *aps_start_addr_slices[MAX_NUM_SLICE_GRPS_IN_LYR]; /*!< array
273                                 to hold the start address of first slice
274                                 of each slice group. the address will be
275                                 linked to each other within a slice
276                                 group based on first MB address
277                                 each entry will be pointing to the slice
278                                 which will be decoded next in the slice
279                                 group
280                                 */
281 
282 } vcl_node_t;
283 /*****************************************************************************/
284 /* Extern Variable Declarations                                              */
285 /*****************************************************************************/
286 
287 /*****************************************************************************/
288 /* Extern Function Declarations                                              */
289 /*****************************************************************************/
290 
291 #endif /* _SVCD_NAL_STRUCTS_H_ */
292