Coverage Report

Created: 2024-07-27 06:35

/src/libavc/decoder/svc/isvcd_nal_parse_structs.h
Line
Count
Source
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_parse_structs.h
23
 *
24
 * \brief
25
 *    Contains the definitions of structures used in the
26
 *      bitstream extraction module
27
 * Detailed_description
28
 *
29
 * \date
30
 *
31
 *
32
 * \author : Kishore
33
 **************************************************************************
34
 */
35
36
#ifndef _SVCD_NAL_PARSE_STRUCTS_H_
37
#define _SVCD_NAL_PARSE_STRUCTS_H_
38
39
/*****************************************************************************/
40
/* File Includes                                                             */
41
/*****************************************************************************/
42
43
/*****************************************************************************/
44
/* Constant Macros                                                           */
45
/*****************************************************************************/
46
47
#define HEADER_BUFFER_LEN_BEFORE_EP 32
48
49
#define MAX_NAL_HEADER_SIZE 4
50
51
7.16M
#define UP_ALIGN_8(x) (((((UWORD64) x) + 7) >> 3) << 3)
52
#define ALIGN_4(x) (((x) + 3) & (~3))
53
54
/*--------------------------------------------------------------------------*/
55
/* The start address of any VCL or NON VCL internal buffers (input to        */
56
/* emulation prevention should be aligned to 4 byte boundary                */
57
/*--------------------------------------------------------------------------*/
58
59
#define BUFFER_ALIGN_4 4
60
61
890k
#define FIRST_PASS 0
62
146k
#define SECOND_PASS 1
63
/*****************************************************************************/
64
/* Function Macros                                                           */
65
/*****************************************************************************/
66
67
static __inline UWORD32 GET_NAL_BUF_INC(WORD32 i4_derived_nal_type)
68
4.14M
{
69
4.14M
    UWORD32 u4_buf_inc;
70
71
4.14M
    if(VCL_NAL == i4_derived_nal_type)
72
1.15M
    {
73
1.15M
        u4_buf_inc = sizeof(vcl_buf_hdr_t);
74
1.15M
    }
75
2.98M
    else
76
2.98M
    {
77
2.98M
        u4_buf_inc = sizeof(non_vcl_buf_hdr_t);
78
2.98M
    }
79
80
4.14M
    u4_buf_inc = UP_ALIGN_8(u4_buf_inc);
81
4.14M
    return (u4_buf_inc);
82
4.14M
}
Unexecuted instantiation: isvcd_api.c:GET_NAL_BUF_INC
Unexecuted instantiation: isvcd_nal.c:GET_NAL_BUF_INC
isvcd_nal_parse.c:GET_NAL_BUF_INC
Line
Count
Source
68
4.14M
{
69
4.14M
    UWORD32 u4_buf_inc;
70
71
4.14M
    if(VCL_NAL == i4_derived_nal_type)
72
1.15M
    {
73
1.15M
        u4_buf_inc = sizeof(vcl_buf_hdr_t);
74
1.15M
    }
75
2.98M
    else
76
2.98M
    {
77
2.98M
        u4_buf_inc = sizeof(non_vcl_buf_hdr_t);
78
2.98M
    }
79
80
4.14M
    u4_buf_inc = UP_ALIGN_8(u4_buf_inc);
81
4.14M
    return (u4_buf_inc);
82
4.14M
}
Unexecuted instantiation: isvcd_parse_epslice.c:GET_NAL_BUF_INC
Unexecuted instantiation: isvcd_parse_headers.c:GET_NAL_BUF_INC
Unexecuted instantiation: isvcd_parse_slice.c:GET_NAL_BUF_INC
Unexecuted instantiation: isvcd_process_ebslice.c:GET_NAL_BUF_INC
Unexecuted instantiation: isvcd_process_epslice.c:GET_NAL_BUF_INC
Unexecuted instantiation: isvcd_thread_compute_bs.c:GET_NAL_BUF_INC
Unexecuted instantiation: isvcd_thread_parse_decode.c:GET_NAL_BUF_INC
Unexecuted instantiation: isvcd_utils.c:GET_NAL_BUF_INC
Unexecuted instantiation: isvcd_vui.c:GET_NAL_BUF_INC
Unexecuted instantiation: isvcd_ii_pred.c:GET_NAL_BUF_INC
Unexecuted instantiation: isvcd_intra_resamp.c:GET_NAL_BUF_INC
Unexecuted instantiation: isvcd_mode_mv_resamp.c:GET_NAL_BUF_INC
Unexecuted instantiation: isvcd_residual_resamp.c:GET_NAL_BUF_INC
Unexecuted instantiation: isvcd_function_selector.c:GET_NAL_BUF_INC
Unexecuted instantiation: isvcd_function_selector_sse42.c:GET_NAL_BUF_INC
Unexecuted instantiation: isvcd_intra_resamp_sse42.c:GET_NAL_BUF_INC
Unexecuted instantiation: isvcd_residual_resamp_sse42.c:GET_NAL_BUF_INC
Unexecuted instantiation: isvcd_cabac.c:GET_NAL_BUF_INC
Unexecuted instantiation: isvcd_compute_bs.c:GET_NAL_BUF_INC
Unexecuted instantiation: isvcd_function_selector_generic.c:GET_NAL_BUF_INC
Unexecuted instantiation: isvcd_mb_utils.c:GET_NAL_BUF_INC
Unexecuted instantiation: isvcd_parse_cavlc.c:GET_NAL_BUF_INC
Unexecuted instantiation: isvcd_parse_ebslice.c:GET_NAL_BUF_INC
Unexecuted instantiation: isvcd_parse_eislice.c:GET_NAL_BUF_INC
83
84
static __inline void UPDATE_NAL_BUF_PTR(UWORD8 **ppu1_buf, WORD32 i4_derived_nal_type,
85
                                        UWORD32 *pu4_bytes_left)
86
1.81M
{
87
1.81M
    UWORD8 *pu1_buf_ptr;
88
1.81M
    UWORD64 u4_inc;
89
90
    /* Align the start of the structure */
91
92
1.81M
    pu1_buf_ptr = *ppu1_buf;
93
94
    /* Account for the vcl or non-vcl header */
95
1.81M
    u4_inc = GET_NAL_BUF_INC(i4_derived_nal_type);
96
1.81M
    u4_inc = UP_ALIGN_8(u4_inc);
97
1.81M
    pu1_buf_ptr += u4_inc;
98
99
    /* Update the pointers */
100
1.81M
    if(*pu4_bytes_left >= u4_inc)
101
1.81M
    {
102
1.81M
        *pu4_bytes_left -= u4_inc;
103
1.81M
    }
104
1.81M
    *ppu1_buf = pu1_buf_ptr;
105
1.81M
}
Unexecuted instantiation: isvcd_api.c:UPDATE_NAL_BUF_PTR
Unexecuted instantiation: isvcd_nal.c:UPDATE_NAL_BUF_PTR
isvcd_nal_parse.c:UPDATE_NAL_BUF_PTR
Line
Count
Source
86
1.81M
{
87
1.81M
    UWORD8 *pu1_buf_ptr;
88
1.81M
    UWORD64 u4_inc;
89
90
    /* Align the start of the structure */
91
92
1.81M
    pu1_buf_ptr = *ppu1_buf;
93
94
    /* Account for the vcl or non-vcl header */
95
1.81M
    u4_inc = GET_NAL_BUF_INC(i4_derived_nal_type);
96
1.81M
    u4_inc = UP_ALIGN_8(u4_inc);
97
1.81M
    pu1_buf_ptr += u4_inc;
98
99
    /* Update the pointers */
100
1.81M
    if(*pu4_bytes_left >= u4_inc)
101
1.81M
    {
102
1.81M
        *pu4_bytes_left -= u4_inc;
103
1.81M
    }
104
1.81M
    *ppu1_buf = pu1_buf_ptr;
105
1.81M
}
Unexecuted instantiation: isvcd_parse_epslice.c:UPDATE_NAL_BUF_PTR
Unexecuted instantiation: isvcd_parse_headers.c:UPDATE_NAL_BUF_PTR
Unexecuted instantiation: isvcd_parse_slice.c:UPDATE_NAL_BUF_PTR
Unexecuted instantiation: isvcd_process_ebslice.c:UPDATE_NAL_BUF_PTR
Unexecuted instantiation: isvcd_process_epslice.c:UPDATE_NAL_BUF_PTR
Unexecuted instantiation: isvcd_thread_compute_bs.c:UPDATE_NAL_BUF_PTR
Unexecuted instantiation: isvcd_thread_parse_decode.c:UPDATE_NAL_BUF_PTR
Unexecuted instantiation: isvcd_utils.c:UPDATE_NAL_BUF_PTR
Unexecuted instantiation: isvcd_vui.c:UPDATE_NAL_BUF_PTR
Unexecuted instantiation: isvcd_ii_pred.c:UPDATE_NAL_BUF_PTR
Unexecuted instantiation: isvcd_intra_resamp.c:UPDATE_NAL_BUF_PTR
Unexecuted instantiation: isvcd_mode_mv_resamp.c:UPDATE_NAL_BUF_PTR
Unexecuted instantiation: isvcd_residual_resamp.c:UPDATE_NAL_BUF_PTR
Unexecuted instantiation: isvcd_function_selector.c:UPDATE_NAL_BUF_PTR
Unexecuted instantiation: isvcd_function_selector_sse42.c:UPDATE_NAL_BUF_PTR
Unexecuted instantiation: isvcd_intra_resamp_sse42.c:UPDATE_NAL_BUF_PTR
Unexecuted instantiation: isvcd_residual_resamp_sse42.c:UPDATE_NAL_BUF_PTR
Unexecuted instantiation: isvcd_cabac.c:UPDATE_NAL_BUF_PTR
Unexecuted instantiation: isvcd_compute_bs.c:UPDATE_NAL_BUF_PTR
Unexecuted instantiation: isvcd_function_selector_generic.c:UPDATE_NAL_BUF_PTR
Unexecuted instantiation: isvcd_mb_utils.c:UPDATE_NAL_BUF_PTR
Unexecuted instantiation: isvcd_parse_cavlc.c:UPDATE_NAL_BUF_PTR
Unexecuted instantiation: isvcd_parse_ebslice.c:UPDATE_NAL_BUF_PTR
Unexecuted instantiation: isvcd_parse_eislice.c:UPDATE_NAL_BUF_PTR
106
107
/*****************************************************************************/
108
/* Typedefs                                                                  */
109
/*****************************************************************************/
110
111
/*****************************************************************************/
112
/* Enums                                                                     */
113
/*****************************************************************************/
114
115
typedef enum
116
{
117
    NAL_PARSE_HANDLE = 0,
118
    NAL_PARSE_DQID_LIST_MEM,
119
    NAL_PARSE_CMN_MEM,
120
    NAL_PARSE_NAL_UNIT_MEM,
121
    NAL_PARSE_NUM_MEM_TABS
122
} BITSTREAM_EXTRACT_MEMTABS_T;
123
124
typedef enum
125
{
126
    PIC_BOUND_DQID = 0,      /* Second slice has lower DQID than the first slice */
127
    PIC_BOUND_SLICE_PRMS = 1 /* Second slice has different slice prms as */
128
                             /* as compared to first slice               */
129
} PIC_BOUNDARY_TYPES_T;
130
131
/*****************************************************************************/
132
/* Structure                                                                 */
133
/*****************************************************************************/
134
135
typedef struct
136
{
137
    vcl_node_t *ps_vcl_node; /*!< The pointer to VCL NAL node buffer.
138
                              */
139
    UWORD8 u1_valid_flag;    /*!< This flag shall indicate that the occupancy of
140
                             vcl node buffer. SVCD_TRUE shall indicate that the vcl
141
                             node buffer is occupied. @sa SVCD_BOOL_T
142
                             */
143
144
    UWORD8 u1_dqid;          /*!< The value of DQID assigned for this structure.
145
                             The range is [0,127] and is computed as
146
                             (Dependency id * 16 + Quality id )
147
                             */
148
    WORD32 i4_poc_lsb;       /*!< It shall have the value of "picture order cnt lsb"
149
                             when picture order count type is 0 for the layer. When not
150
                             present in the bitstream, it shall be set to 0*/
151
152
    WORD32
153
    i4_delta_poc_bot; /*!< It shall have the value of "delta picture order cnt
154
                 bottom" when picture order count type is 0 for VCL NAL unit.
155
                 When not present in the bitstream, it shall be set to 0*/
156
157
    WORD32
158
    ai4_delta_poc[2]; /*!< It shall have the value of "delta picture order cnt
159
                   bottom" when picture order count type is 1 for VCL NAL
160
                   unit.
161
                   When not present in the bitstream, itshall be set to 0 */
162
} dqid_node_t;
163
164
typedef struct
165
{
166
    WORD32 i4_max_num_lyrs;    /*!< Maximum number of layers that will be
167
                       present in a access unit. This will determine the
168
                       length of the VCL NAL node buffer. This parameter
169
                       is configurable during instance creation time
170
                       */
171
172
    dqid_node_t *ps_dqid_node; /*!< Pointer to start of VCL NAL node buffer.
173
                                */
174
175
} dqid_ctxt_t;
176
177
typedef struct
178
{
179
    WORD32 i4_valid_flag; /*!< It shall indicate the validity of contents of
180
                          this buffer structure. SVCD_TRUE shall indicate
181
                          that the contents of this structure is valid.
182
                          @sa SVCD_BOOL_T
183
                          */
184
185
    UWORD8 *pu1_buf;      /*!< It shall point to start of SODB data of the NAL.
186
                          It should be 8 byte aligned.
187
                          */
188
189
    UWORD32 u4_max_bits;  /*!< The length of SODB data of NAL in bits. This
190
                          should be set properly by taking care of whether NAL
191
                          is coded in CAVLC or CABAC or NAL is a NON VCL NAL
192
                          */
193
194
    WORD32 i4_buf_size;   /*!< The size of SODB data of NAL in bytes
195
                           */
196
} nal_buf_t;
197
198
typedef struct
199
{
200
    /*----------------------------------------------------*/
201
    /*---------- Mode of operation -----------------------*/
202
    /*----------------------------------------------------*/
203
204
    WORD32 i4_input_bitstream_mode; /*!< RFC or Annex B   */
205
206
    /*----------------------------------------------------*/
207
    /*---------- NAL boundary detection ------------------*/
208
    /*----------------------------------------------------*/
209
210
    WORD32 i4_find_nal_state;   /*!< state of NAL boundary
211
                       detection logic */
212
213
    WORD32 i4_zero_byte_cnt;    /*< Number of zero bytes consumed */
214
215
    WORD32 i4_dec_frst_sc_flag; /*!< A flag to decode
216
                    the start code only. A value of SVCD_TRUE
217
                    shall indicate that start code shall be
218
                    decoded.@sa SVCD_BOOL_T */
219
220
    /*----------------------------------------------------*/
221
    /*--------- Emulation prevention info ----------------*/
222
    /*----------------------------------------------------*/
223
224
    emulation_prevent_ctxt_t s_emulation_ctxt;
225
226
    /*----------------------------------------------------*/
227
    /*--------- Picture boundary detetction info ---------*/
228
    /*----------------------------------------------------*/
229
230
    WORD32 i4_is_frst_vcl_nal_in_au; /*!< Indicates whether
231
                     current NAL is first NAL in the current
232
                     Access unit. This is needed for detecting
233
                     picture boundary in partial input mode of
234
                     operation */
235
236
    UWORD32 u4_time_stamp_lsb;       /*!< Holds the LSB of time stamp of the
237
                         first NAL unit in the  access unit.
238
                         Used for RFC based bitstreams */
239
240
    WORD32 i4_time_stamp_msb;        /*!< Holds the MSB of time stamp of the
241
                         first NAL unit in the  access unit.
242
                         Used for RFC based bitstreams */
243
244
    WORD32 i4_prev_dq_id;            /*!< Holds the value of DQID of
245
                               last NAL unit parsed. this is used for
246
                               detetecting the picture boundary.
247
                               in Annex B mode of input bitstream */
248
    WORD32 i4_idr_pic_err_flag;      /*!< place to hold the
249
                          IDR status of current AU
250
                          */
251
252
    /*----------------------------------------------------*/
253
    /*-------- DQID node context -------------------------*/
254
    /*----------------------------------------------------*/
255
256
    dqid_ctxt_t s_dqid_ctxt;
257
258
    /*----------------------------------------------------*/
259
    /*-------- VCL and NON VCL buf info ------------------*/
260
    /*----------------------------------------------------*/
261
262
    void *pv_non_vcl_nal_buf;               /*!< Start address of NON VCL
263
                                  NAL buffer */
264
265
    void *pv_vcl_nal_buf;                   /*!< Start address of VCL NAL
266
                                    buffer */
267
268
    UWORD32 u4_bytes_left_vcl;              /*!< number of bytes left in the
269
                                            VCL buffer
270
                                            */
271
    UWORD32 u4_bytes_left_non_vcl;          /*!< number of bytes left in the
272
                                        NON VCL buffer
273
                                        */
274
275
    UWORD8 *pu1_non_vcl_nal_buf;            /*!< Current position of
276
                               non VCL NAL buffer pointer */
277
278
    UWORD8 *pu1_vcl_nal_buf;                /*!< Current position of VCL NAL
279
                                   buffer pointer */
280
281
    WORD32 i4_num_non_vcl_nals;             /*!< Number of non vcl nals */
282
283
    nal_buf_t s_prefix_nal_buf;             /*!< NAL buffer structure
284
                            of prefix NAL unit */
285
286
    nal_buf_t s_nal_buf;                    /*!< NAL buffer structure of .
287
                                     active NAL unit ( which is not a prefix
288
                                     NAL unit) */
289
290
    nal_buf_t *ps_nal_buf;                  /*!< It shall point to active
291
                                  NAL buffer structure. It shall point to
292
                                  either "s_prefix_nal_buf" or "s_nal_buf"*/
293
294
    vcl_buf_hdr_t *ps_prev_vcl_buf;         /*!< It shall point
295
                          to vcl buffer header of the previous
296
                          slice of a layer */
297
    non_vcl_buf_hdr_t *ps_prev_non_vcl_buf; /*!< It shall
298
                      point to buffer header of the previous
299
                      non vcl nal present in the bitstream */
300
301
    /*----------------------------------------------------*/
302
    /*-------- NAL structure and NAL buffer --------------*/
303
    /*----------------------------------------------------*/
304
305
    void *pv_nal_unit;
306
    void *pv_nal_header_buf;
307
    nal_prms_t s_nal_prms;
308
    nal_prms_t s_prefix_nal_prms;
309
310
    /*----------------------------------------------------*/
311
    /*-------------- Target layer info -------------------*/
312
    /*----------------------------------------------------*/
313
314
    target_lyr_attr_t s_app_attr; /*!< This structure shall have
315
                                  the target layer attributes set
316
                                  by the application */
317
318
    target_lyr_attr_t s_int_attr; /*!< This structure shall have
319
                                  the target layer attributes set
320
                                  by the module. At any state, the
321
                                  module tries to attain the values
322
                                  of application attributes at
323
                                  the IDR pictures */
324
325
    WORD32 i4_tgt_lyr_update;     /*!< It is a flag which
326
                                  indicates whether the internal target layer
327
                                  attributes has to be updated or not. A value
328
                                  of SVCD_TRUE shall indicate that the target
329
                                  layer attributes shall be updated.
330
                                  @sa SVCD_BOOL_T */
331
332
    /*----------------------------------------------------*/
333
    /*-------- other NAL info ----------------------------*/
334
    /*----------------------------------------------------*/
335
336
    WORD32 i4_discard_nal_flag;
337
    WORD32 i4_nal_type;
338
339
    /*----------------------------------------------------*/
340
    /*---------- Seq, pic prms buffers -------------------*/
341
    /*----------------------------------------------------*/
342
343
    void *pv_seq_prms;
344
    void *pv_pic_prms;
345
346
    /*----------------------------------------------------*/
347
    /*----------        Others          ------------------*/
348
    /*----------------------------------------------------*/
349
350
    WORD32 i4_eos_flag;    /*!< Flush mode related parameter.
351
                   This is used by the module during the
352
                   flush call. SVCD_TRUE shall indicate that
353
                   current  end of bitstream has occurred.
354
                   @sa SVCD_BOOL_T; */
355
356
    UWORD32 u4_bytes_left; /*!< This field has number of bytes not
357
                    consumed by the NAL parse module in the
358
                    previous call because of insufficient bitstream
359
                    to decode the slice and NAL header. */
360
    UWORD8 u1_pic_boundary_aud_flag;
361
} nal_parse_ctxt_t;
362
363
/*****************************************************************************/
364
/* Extern Variable Declarations                                              */
365
/*****************************************************************************/
366
367
/*****************************************************************************/
368
/* Extern Function Declarations                                              */
369
/*****************************************************************************/
370
371
#endif /* _SVCD_NAL_PARSE_STRUCTS_H_ */